aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.52k stars 3.86k forks source link

(synthetics): Default role breaks in non aws partitions #12094

Closed Khufu-I closed 3 years ago

Khufu-I commented 3 years ago

Synthetics Canary default execution role hard codes 'arn:aws:logs:::*' in the IAM policy which does not work in non AWS partitions (i.e aws-cn or aws-us-gov)

Reproduction Steps

Synthesize the following code (cdk synth) for cn-north-1

import * as synthetics from '@aws-cdk/aws-synthetics';

const canary = new synthetics.Canary(this, 'MyCanary', {
  schedule: synthetics.Schedule.rate(Duration.minutes(5)),
  test: Test.custom({
    code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
    handler: 'index.handler',
  }),
  runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0,
});

What did you expect to happen?

The default execution role IAM policy should contain a partition aware log access policy

{
  "Action": [
    "logs:CreateLogStream",
    "logs:CreateLogGroup",
    "logs:PutLogEvents"
  ],
  "Effect": "Allow",
  "Resource": { "Fn::Join": ["", ["arn:", {"Ref": "AWS::Partition"}, ":logs:::*"]] }
}

What actually happened?

The default execution role contains an IAM policy which has aws hardcoded and isn't partition aware

{
  "Action": [
    "logs:CreateLogStream",
    "logs:CreateLogGroup",
    "logs:PutLogEvents"
  ],
  "Effect": "Allow",
  "Resource": "arn:aws:logs:::*"
}

Environment

Other


This is :bug: Bug Report

github-actions[bot] commented 3 years ago

⚠️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.