-
Notifications
You must be signed in to change notification settings - Fork 555
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
Add iam_tags to vault_aws_secret_backend_role resource #2087
Conversation
This reverts commit b2223e6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pporee, this PR seems to break some of the acceptance tests (see below for an example). Local test setup guides can be found at https://github.com/hashicorp/terraform-provider-vault/blob/main/README.md#developing-the-provider. Could you take a look and drop your acceptance tests' output in the description like #781's?
~/go/src/github.com/community/pporee/terraform-provider-vault (main) $ make testacc TESTARGS='-run=TestAccAWSSecretBackendRole'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test -run=TestAccAWSSecretBackendRole -timeout 30m ./...
? github.com/hashicorp/terraform-provider-vault [no test files]
? github.com/hashicorp/terraform-provider-vault/cmd/coverage [no test files]
? github.com/hashicorp/terraform-provider-vault/cmd/generate [no test files]
? github.com/hashicorp/terraform-provider-vault/helper [no test files]
? github.com/hashicorp/terraform-provider-vault/internal/consts [no test files]
? github.com/hashicorp/terraform-provider-vault/internal/identity/group [no test files]
? github.com/hashicorp/terraform-provider-vault/internal/identity/mfa [no test files]
? github.com/hashicorp/terraform-provider-vault/internal/pki [no test files]
ok github.com/hashicorp/terraform-provider-vault/codegen (cached) [no tests to run]
ok github.com/hashicorp/terraform-provider-vault/internal/identity/entity (cached) [no tests to run]
? github.com/hashicorp/terraform-provider-vault/schema [no test files]
ok github.com/hashicorp/terraform-provider-vault/internal/provider (cached) [no tests to run]
ok github.com/hashicorp/terraform-provider-vault/testutil (cached) [no tests to run]
ok github.com/hashicorp/terraform-provider-vault/util (cached) [no tests to run]
--- FAIL: TestAccAWSSecretBackendRole_import (2.63s)
resource_aws_secret_backend_role_test.go:61: Step 2/6 error running import: ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import.
map[string]string{
- "iam_tags.%": "2",
- "iam_tags.key1": "value1",
- "iam_tags.key2": "value2",
}
FAIL
FAIL github.com/hashicorp/terraform-provider-vault/vault 12.007s
FAIL
make: *** [testacc] Error 1
Please let us know if you need any help.
Thanks,
Thy
@@ -145,6 +145,8 @@ func testAccAWSSecretBackendRoleCheckBasicAttributes(name, backend string) resou | |||
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "backend", backend), | |||
testutil.TestCheckResourceAttrJSON("vault_aws_secret_backend_role.test_policy_inline", "policy_document", testAccAWSSecretBackendRolePolicyInline_basic), | |||
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_groups.#", "0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think another test for the map's key length can ensure the map value.
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_groups.#", "0"), | |
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_groups.#", "0"), | |
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_tags.%", "2"), |
@@ -177,6 +179,8 @@ func testAccAWSSecretBackendRoleCheckUpdatedAttributes(name, backend string) res | |||
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "default_sts_ttl", "3600"), | |||
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "max_sts_ttl", "21600"), | |||
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_groups.#", "2"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_groups.#", "2"), | |
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_groups.#", "2"), | |
resource.TestCheckResourceAttr("vault_aws_secret_backend_role.test_policy_inline", "iam_tags.%", "2"), |
@@ -123,6 +131,8 @@ func awsSecretBackendRoleWrite(d *schema.ResourceData, meta interface{}) error { | |||
|
|||
iamGroups := d.Get("iam_groups").(*schema.Set).List() | |||
|
|||
iamTags, iamTagsOk := d.GetOk("iam_tags") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get will return the data for the given key, or nil if the key doesn't exist in the schema.
iamTags, iamTagsOk := d.GetOk("iam_tags") | |
iamTags := d.Get("iam_tags") |
@@ -155,6 +165,9 @@ func awsSecretBackendRoleWrite(d *schema.ResourceData, meta interface{}) error { | |||
if d.HasChange("iam_groups") { | |||
data["iam_groups"] = iamGroups | |||
} | |||
if iamTagsOk { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also check if the value has changed, following the current practice from other fields/keys.
if iamTagsOk { | |
if d.HasChange("iam_tags") { |
@@ -233,6 +241,10 @@ resource "vault_aws_secret_backend_role" "test_policy_arns" { | |||
policy_arns = ["%s"] | |||
credential_type = "iam_user" | |||
backend = vault_aws_secret_backend.test.path | |||
iam_tags = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like resource.TestCheckResourceAttr(...)
tests for iam_tags
of resource "vault_aws_secret_backend_role.test_policy_arns" are missing.
Could you please enhance its test coverage like how you did for resource "vault_aws_secret_backend_role.test_policy_inline"?
iam_tags = { | ||
"key1" = "value1" | ||
"key2" = "value2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment to the above to enhance test coverage.
iam_tags = { | ||
"key1" = "value1" | ||
"key2" = "value2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment to the above to enhance test coverage.
iam_tags = { | ||
"key1" = "value1" | ||
"key2" = "value2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment to the above to enhance test coverage.
iam_tags = { | ||
"key1" = "value1" | ||
"key2" = "value2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iam_tags = { | |
"key1" = "value1" | |
"key2" = "value2" | |
} | |
iam_tags = { | |
"key1" = "value1" | |
"key2" = "value2" | |
} |
iam_tags = { | ||
"key1" = "value1" | ||
"key2" = "value2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iam_tags = { | |
"key1" = "value1" | |
"key2" = "value2" | |
} | |
iam_tags = { | |
"key1" = "value1" | |
"key2" = "value2" | |
} |
Hello! I am interested in this because it will allow us to use AWS policy variables in our IAM policies. Without this we cannot do that and thus cannot use AWS Policy variables based off of tags |
@Shocktrooper Thank you for your patience! I've created a WIP #2231 to finish the remaining work and close this PR. |
Thank you for picking this up! @thyton Let me know if there is anything I can do |
@pporee @Shocktrooper This feature will be out in release 4.3.0. Thank you again for your patience! |
Description
Fix #1073
Relates OR Closes #0000
Checklist
Output from acceptance testing:
Community Note