Skip to content
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

Policy Deletes and Recreate on its own #69

Open
Eliran-b opened this issue Sep 11, 2023 · 0 comments
Open

Policy Deletes and Recreate on its own #69

Eliran-b opened this issue Sep 11, 2023 · 0 comments
Labels
bug 🐛 An issue with the system

Comments

@Eliran-b
Copy link

Describe the Bug

When creating a multiple statements policy Terraform deletes or creates the second policy every time.

When running first apply the policy created successfully (as it should be).

when running the second apply command (without any code changes) the result is the second statement will be deleted.

module definition:

module "my-topic" {
source = "cloudposse/sns-topic/aws"
version = "~> 0.21.0"

name = "env-${var.environment}-batch-manager-topic"
allowed_aws_services_for_sns_published = ["s3.amazonaws.com"]
subscribers = {
my_lambda = {
protocol = "lambda"
endpoint = module.my-lambda.lambda_function_arn
endpoint_auto_confirms = false
raw_message_delivery = false
},
}

encryption_enabled = false
sns_topic_policy_json = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Sid" : "AllowSNSS3BucketNotification",
"Effect" : "Allow",
"Principal" : {
"Service" : "s3.amazonaws.com"
},
"Action" : "sns:Publish",
"Resource" : module.my-topic.sns_topic_arn,
"Condition" : {
"ArnEquals" : {
"aws:SourceArn" : module.my-bucket.s3_bucket_arn
}
}
},
{
"Sid" : "Allow-AccountB-To-Subscribe",
"Effect" : "Allow",
"Principal" : {
"AWS" : "arn:aws:iam::some-iam"
},
"Action" : "sns:Subscribe",
"Resource" : module.batch-manager-topic.sns_topic_arn
},
]
})
}

Expected Behavior

The required outcome should be that the second statement won't deleted in the second apply command and there will be no changes to apply.

Steps to Reproduce

create an sns topic with more than one statement policy

Screenshots

first apply:

image

second apply:

image

Environment

No response

Additional Context

No response

@Eliran-b Eliran-b added the bug 🐛 An issue with the system label Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant