diff --git a/.changelog/2444.txt b/.changelog/2444.txt new file mode 100644 index 0000000000..058e455bfe --- /dev/null +++ b/.changelog/2444.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_ssm_ssh_key_pair_secret: Fix ssh_key_name problem +``` diff --git a/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret.go b/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret.go index 54c050b114..bc069b144d 100644 --- a/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret.go +++ b/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret.go @@ -49,6 +49,7 @@ func ResourceTencentCloudSsmSshKeyPairSecret() *schema.Resource { }, "ssh_key_name": { Optional: true, + Computed: true, Type: schema.TypeString, Description: "Name of the SSH key pair, which only contains digits, letters and underscores and must start with a digit or letter. The maximum length is 25 characters.", }, diff --git a/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret_test.go b/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret_test.go index b96349d024..1a7c09906f 100644 --- a/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret_test.go +++ b/tencentcloud/services/ssm/resource_tc_ssm_ssh_key_pair_secret_test.go @@ -62,6 +62,26 @@ func TestAccTencentCloudSsmSshKeyPairSecretResource_basic(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"clean_ssh_key"}, }, + { + Config: testAccSsmSshKeyPairSecretNoName, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_ssm_ssh_key_pair_secret.example2", "description", "desc."), + resource.TestCheckResourceAttr("tencentcloud_ssm_ssh_key_pair_secret.example2", "status", "Disabled"), + ), + }, + { + Config: testAccSsmSshKeyPairSecretNoNameUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_ssm_ssh_key_pair_secret.example2", "description", "update desc."), + resource.TestCheckResourceAttr("tencentcloud_ssm_ssh_key_pair_secret.example2", "status", "Enabled"), + ), + }, + { + ResourceName: "tencentcloud_ssm_ssh_key_pair_secret.example2", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"clean_ssh_key"}, + }, }, }) } @@ -149,3 +169,31 @@ resource "tencentcloud_ssm_ssh_key_pair_secret" "example1" { } } ` + +const testAccSsmSshKeyPairSecretNoName = ` +resource "tencentcloud_ssm_ssh_key_pair_secret" "example2" { + secret_name = "tf-example-ssh-test-no-id" + project_id = 0 + description = "desc." + status = "Disabled" + clean_ssh_key = true + + tags = { + createdBy = "terraform" + } +} +` + +const testAccSsmSshKeyPairSecretNoNameUpdate = ` +resource "tencentcloud_ssm_ssh_key_pair_secret" "example2" { + secret_name = "tf-example-ssh-test-no-id" + project_id = 0 + description = "update desc." + status = "Enabled" + clean_ssh_key = true + + tags = { + createdBy = "terraform" + } +} +`