terraform-provider-awscc
terraform-provider-awscc copied to clipboard
[Bug]: Tags for IoT Authorizer Introduce Drift
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
- The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.
Terraform CLI and Terraform AWS Cloud Control Provider Version
Terraform: 1.7.5 Provider: 0.74.0
Affected Resource(s)
-
awscc_iot_authorizer
Terraform Configuration Files
resource "awscc_iam_role" "this" {
role_name = "test"
assume_role_policy_document = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "lambda.amazonaws.com"
}
},
]
})
}
data "archive_file" "this" {
type = "zip"
source_content = "export function handler() {}"
source_content_filename = "index.js"
output_path = "lambda_function_payload.zip"
}
resource "awscc_lambda_function" "this" {
function_name = "lambda_function_name"
code = {
zip_file = data.archive_file.this.output_path
}
package_type = "Zip"
handler = "index.handler"
runtime = "nodejs20.x"
timeout = "300"
memory_size = "128"
role = awscc_iam_role.this.arn
architectures = ["arm64"]
}
resource "awscc_lambda_permission" "with_sns" {
action = "lambda:InvokeFunction"
function_name = awscc_lambda_function.this.function_name
principal = "iot.amazonaws.com"
source_arn = awscc_iot_authorizer.this.arn
}
resource "awscc_iot_authorizer" "this" {
authorizer_function_arn = awscc_lambda_function.this.arn
authorizer_name = "test"
enable_caching_for_http = true
signing_disabled = true
status = "ACTIVE"
tags = [
{
key = "b"
value = "test"
},
{
key = "a"
value = "test"
}
]
}
Panic Output
# awscc_iot_authorizer.this will be updated in-place
~ resource "awscc_iot_authorizer" "this" {
id = "test"
~ tags = [
~ {
~ key = "a" -> "b"
value = "test"
},
~ {
~ key = "b" -> "a"
value = "test"
},
]
+ token_key_name = (known after apply)
# (7 unchanged attributes hidden)
}
Expected Behavior
If no changes were made to the config there should not be any changes to the plan.
Actual Behavior
If the tags
array is not ordered alphabetically on initial apply, subsequent deployments will always detect drift for that property. Changing the order afterwards will not fix the problem since re-ordering of tags is never applied.
Steps to Reproduce
-
terraform apply
with the provided Terraform config. -
terraform apply
again with the same config.
For this particular resource, the tag has insertionOrder
set to true.
aws cloudformation describe-type --type RESOURCE --type-name AWS::IoT::Authorizer | jq -r ".Schema" | jq ".properties.Tags"
{
"type": "array",
"insertionOrder": true,
"items": {
"$ref": "#/definitions/Tag"
}
}
this is an upstream issue, the schema should be updated , thanks for reporting this problem.