Skip to content

Fix/ssm #2444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 3, 2024
Merged

Fix/ssm #2444

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2444.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_ssm_ssh_key_pair_secret: Fix ssh_key_name problem
```
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func ResourceTencentCloudSsmSshKeyPairSecret() *schema.Resource {
},
"ssh_key_name": {
Optional: true,
Computed: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为啥增加 computed 呢

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个字段如果不填写,云API会默认返回值,这样会出现change,所以要增加computed

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.",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
},
})
}
Expand Down Expand Up @@ -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"
}
}
`