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

(pipelines): (ArtifactsBucketB94BC086 missing Allow Policy on cross-region deployments) #28187

Closed
nonken opened this issue Nov 29, 2023 · 2 comments
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@nonken
Copy link
Contributor

nonken commented Nov 29, 2023

Describe the bug

  1. I have a pipeline deployed into us-east-1
  2. The pipelines deploys a stage into eu-west-2

When synthesize the pipeline cloudformation template, I am getting the following policy:

{
  "ServiceApiPipelineArtifactsBucketPolicyD1CACCB2": {
    "Type": "AWS::S3::BucketPolicy",
    "Properties": {
      "Bucket": {
        "Ref": "ServiceApiPipelineArtifactsBucketB94BC086"
      },
      "PolicyDocument": {
        "Statement": [
          {
            "Action": "s3:*",
            "Condition": {
              "Bool": {
                "aws:SecureTransport": "false"
              }
            },
            "Effect": "Deny",
            "Principal": {
              "AWS": "*"
            },
            "Resource": [
              {
                "Fn::GetAtt": [
                  "ServiceApiPipelineArtifactsBucketB94BC086",
                  "Arn"
                ]
              },
              {
                "Fn::Join": [
                  "",
                  [
                    {
                      "Fn::GetAtt": [
                        "ServiceApiPipelineArtifactsBucketB94BC086",
                        "Arn"
                      ]
                    },
                    "/*"
                  ]
                ]
              }
            ]
          }
        ],
        "Version": "2012-10-17"
      }
    }
  }

This policy only denies access and subsequently the prepare step fails with s S3 403 error.

Wen I add another stage, in the same region as the pipeline (us-east-1), then I get the correcy policy:

{
  "ServiceApiPipelineArtifactsBucketPolicyD1CACCB2": {
    "Type": "AWS::S3::BucketPolicy",
    "Properties": {
      "Bucket": {
        "Ref": "ServiceApiPipelineArtifactsBucketB94BC086"
      },
      "PolicyDocument": {
        "Statement": [
          {
            "Action": "s3:*",
            "Condition": {
              "Bool": {
                "aws:SecureTransport": "false"
              }
            },
            "Effect": "Deny",
            "Principal": {
              "AWS": "*"
            },
            "Resource": [
              {
                "Fn::GetAtt": [
                  "ServiceApiPipelineArtifactsBucketB94BC086",
                  "Arn"
                ]
              },
              {
                "Fn::Join": [
                  "",
                  [
                    {
                      "Fn::GetAtt": [
                        "ServiceApiPipelineArtifactsBucketB94BC086",
                        "Arn"
                      ]
                    },
                    "/*"
                  ]
                ]
              }
            ]
          },
          {
            "Action": [
              "s3:GetBucket*",
              "s3:GetObject*",
              "s3:List*"
            ],
            "Effect": "Allow",
            "Principal": {
              "AWS": {
                "Fn::Join": [
                  "",
                  [
                    "arn:",
                    {
                      "Ref": "AWS::Partition"
                    },
                    ":iam::ACCOUNT_ID:role/cdk-hnb659fds-deploy-role-ACCOUNT_ID-us-east-1"
                  ]
                ]
              }
            },
            "Resource": [
              {
                "Fn::GetAtt": [
                  "ServiceApiPipelineArtifactsBucketB94BC086",
                  "Arn"
                ]
              },
              {
                "Fn::Join": [
                  "",
                  [
                    {
                      "Fn::GetAtt": [
                        "ServiceApiPipelineArtifactsBucketB94BC086",
                        "Arn"
                      ]
                    },
                    "/*"
                  ]
                ]
              }
            ]
          }
        ],
        "Version": "2012-10-17"
      }
    }
  }

Expected Behavior

I would expect the policy to allow accessing S3 also when just deploying into one other region.

Current Behavior

See above.

Reproduction Steps

See above.

Possible Solution

No response

Additional Information/Context

I tried this with the latest version of the CDK as well to no success.

CDK CLI Version

2.102.0

Framework Version

No response

Node.js Version

18.16

OS

OSX

Language

TypeScript

Language Version

No response

Other information

No response

@nonken nonken added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2023
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Nov 29, 2023
@nonken
Copy link
Contributor Author

nonken commented Nov 30, 2023

@nonken nonken closed this as completed Nov 30, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant