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

Wrong output during terraform plan #24

Open
1 task done
bharti8085 opened this issue Apr 17, 2023 · 1 comment
Open
1 task done

Wrong output during terraform plan #24

bharti8085 opened this issue Apr 17, 2023 · 1 comment
Labels
⚠️ bug Categorize bug reports.

Comments

@bharti8085
Copy link

bharti8085 commented Apr 17, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

I am using following resource block:

resource "aws_kms_key_policy" "cmk" {
key_id = data.aws_kms_key.by_alias.id
policy = jsonencode({

"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "SId#1",
        "Effect": "Allow",
        "Principal": {
            "AWS": "arn:aws:iam::123456789:root"
        },
        "Action": "kms:CreateGrant",
        "Resource": "*",
        "Condition": {
            "StringEquals": {
                "kms:CallerAccount": "123456789",
                "kms:GranteePrincipal": "arn:aws:iam::123456789:role/aws-service-role/mgn.amazonaws.com/AWSServiceRoleForApplicationMigrationService"
            },
            "ForAllValues:StringEquals": {
                "kms:GrantOperations": [
                    "CreateGrant",
                    "DescribeKey",
                    "Encrypt",
                    "Decrypt",
                    "GenerateDataKey",
                    "GenerateDataKeyWithoutPlaintext"
                ]
            },
            "Bool": {
                "aws:ViaAWSService": "true"
            }
        }
    },
    {
        "Sid": "Sid#2",
        "Effect": "Allow",
        "Principal": {
            "AWS": [
                "arn:aws:iam::123456789:root",
                "arn:aws:iam::123456789:role/aws-service-role/mgn.amazonaws.com/AWSServiceRoleForApplicationMigrationService"
            ]
        },
        "Action": [
            "kms:ReEncrypt*",
            "kms:GenerateDataKey*"
        ],
        "Resource": "*",
        "Condition": {
            "StringEquals": {
                "kms:CallerAccount": "123456789",
                "kms:ViaService": "ec2.us-east-1.amazonaws.com"
            }
        }
    }
]

}
)
}

terraform plan output

                          + "kms:CallerAccount"    = "123456789"
                          + "kms:GranteePrincipal" = "arn:aws:iam::123456789:role/aws-service-role/mgn.amazonaws.com/AWSServiceRoleForApplicationMigrationService"
                        }
                    }
                  + Effect    = "Allow"
                  + Principal = {
                      + AWS = "arn:aws:iam::123456789:root"
                    }
                  + Resource  = "*"
                  + Sid       = "Sid#2"
                },
              + {
                  + Action    = [
                      + "kms:ReEncrypt*",
                      + "kms:GenerateDataKey*",
                    ]
                  + Condition = {
                      + StringEquals = {
                          + "kms:CallerAccount" = "123456789"
                          + "kms:ViaService"    = "ec2.***.amazonaws.com"
                        }
                    }
                  + Effect    = "Allow"
                  + Principal = {
                      + AWS = [
                          + "arn:aws:iam::123456789:root",
                          + "arn:aws:iam::123456789:role/aws-service-role/mgn.amazonaws.com/AWSServiceRoleForApplicationMigrationService",
                        ]
                    }
                  + Resource  = "*"
                  + Sid       = "Sid#1"
                },
            ]
          + Version   = "2012-10-17"
        }
    )
}

I don't understand why the kms:ViaService = ec2..amazonaws.com in output with three star () rather than exact region name.

Steps To Reproduce

provider "aws" {
region = var.region
}

terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}

Which version of the app are you using?

1.0.0, 1.1.0, 1.2.0

@bharti8085 bharti8085 added the ⚠️ bug Categorize bug reports. label Apr 17, 2023
@github-actions
Copy link

👋 Welcome! Looks like this is your first issue.

Hey, thanks for your contribution! Please give us a bit of time to review it. 😄

Be sure to follow the issue template!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ bug Categorize bug reports.
Projects
None yet
Development

No branches or pull requests

1 participant