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

(cdk-pipelines): Build fails after updating CDK to 1.87.0 - not authorized to perform: ssm:GetParameters on resource: arn:aws:ssm:eu-central-1:88888888:parameter/ENV_VARIABLE status code: 400, request id #12742

Closed
markusl opened this issue Jan 28, 2021 · 11 comments · Fixed by #12761
Assignees
Labels
@aws-cdk/aws-codepipeline-actions bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1

Comments

@markusl
Copy link
Contributor

markusl commented Jan 28, 2021

It seems handling of the secrets has been changed in AWS CDK 1.87.0 so that the required ssm:GetParameters policy is not created any more.

Reproduction Steps

  const secrets = { 
    'ENV_VARIABLE': ecs.Secret.fromSsmParameter(ssmParameters.envVariable),
  };

  const taskDefinition = new ecs.FargateTaskDefinition(scope, `${serviceName}TaskDefinition`);
  const mainContainer = taskDefinition.addContainer('main', {
    image: ecs.ContainerImage.fromAsset('../service',
      {
        buildArgs: {
        }
      }),
    logging,
    secrets,
  });

What did you expect to happen?

I would not expect to see any diff in IAM roles after upgrading.

What actually happened?


Decrypted Variables Error: AccessDeniedException: User: arn:aws:sts::88888888:assumed-role/build/AWSCodeBuild-bc7324e2-a3f5-4638-9675-54d90553cc3a is not authorized to perform: ssm:GetParameters on resource: arn:aws:ssm:eu-central-1:207507657282:parameter/dev/ENV_VARIABLE status code: 400, request id: cada8842-0a21-473c-be49-7b16f580f60c


Environment

  • CDK CLI Version : 1.87.0
  • Framework Version: 1.87.0
  • Node.js Version:
  • OS : macOS
  • Language (Version): TypeScript

Other


This is 🐛 Bug Report

@markusl markusl added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 28, 2021
@markusl markusl changed the title (cdk-pipelines): Build fails after updating CDK to 1.87.0 - arn:aws:sts::207507657282:assumed-role/role/AWSCodeBuild-bc7324e2-a3f5-4638-9675-54d90553cc3a is not authorized to perform: ssm:GetParameters on resource: arn:aws:ssm:eu-central-1:88888888:parameter/ENV_VARIABLE status code: 400, request id (cdk-pipelines): Build fails after updating CDK to 1.87.0 - not authorized to perform: ssm:GetParameters on resource: arn:aws:ssm:eu-central-1:88888888:parameter/ENV_VARIABLE status code: 400, request id Jan 28, 2021
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Jan 28, 2021
@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 28, 2021

This seems to be an ECS issue, agreed?

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 28, 2021

You did not say WHEN the error occurred.

During a synth, or during the CloudFormation deployment, or during the run of the ECS container that is a result of the deployment, or... ?

@rix0rrr rix0rrr added @aws-cdk/aws-ecs Related to Amazon Elastic Container and removed @aws-cdk/pipelines CDK Pipelines library labels Jan 28, 2021
@rix0rrr rix0rrr assigned MrArnoldPalmer and unassigned rix0rrr Jan 28, 2021
@markusl
Copy link
Contributor Author

markusl commented Jan 28, 2021

@rix0rrr This happened during the build of the Docker asset in question

@markusl
Copy link
Contributor Author

markusl commented Jan 28, 2021

Also the following code specifying environmentVariables seems to fail with 1.87.0

    synthAction: pipelines.SimpleSynthAction.standardNpmSynth({
      sourceArtifact,
      cloudAssemblyArtifact,

      subdirectory: 'cdk',
      environmentVariables: {
        NPM_TOKEN: {
          type: codebuild.BuildEnvironmentVariableType.PARAMETER_STORE,
          value: 'npm-token'
        },
      },
    }),

Is it possibly due to this? 736b260#diff-d3cb29eee3f26a140a30213c958a5739b9abbae4ba62f3d6318417ef6ac8f930L323

skinny85 added a commit to skinny85/aws-cdk that referenced this issue Jan 29, 2021
…iables

We correctly added permissions for SSM and SecretsManager-type environment variables set on the CodeBuild Project itself,
but we forgot that environment variables could also be set on the CodeBuild CodePipeline action.

Fixes aws#12742
@skinny85 skinny85 assigned skinny85 and unassigned MrArnoldPalmer Jan 29, 2021
@skinny85 skinny85 added @aws-cdk/aws-codepipeline-actions effort/small Small work item – less than a day of effort p1 in-progress This issue is being actively worked on. and removed @aws-cdk/aws-ecs Related to Amazon Elastic Container needs-triage This issue or PR still needs to be triaged. labels Jan 29, 2021
@skinny85
Copy link
Contributor

Thanks for reporting @markusl. You are correct about the reason. PR with a fix posted.

@mergify mergify bot closed this as completed in #12761 Jan 29, 2021
mergify bot pushed a commit that referenced this issue Jan 29, 2021
…iables (#12761)

We correctly added permissions for SSM and SecretsManager-type environment variables set on the CodeBuild Project itself,
but we forgot that environment variables could also be set on the CodeBuild CodePipeline action.

Fixes #12742

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
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.

@markusl
Copy link
Contributor Author

markusl commented Jan 29, 2021

@skinny85 @rix0rrr is the fix going to be included in v1.87.1?

@skinny85
Copy link
Contributor

Unfortunately no - 1.87.1 was just a hotfix for a serious bug in 1.87.0. This fix should be included in 1.88.0, which should be out next week.

Apologies for the inconvenience this caused @markusl!

@skinny85
Copy link
Contributor

skinny85 commented Jan 29, 2021

Perhaps rolling back to 1.86.0 until 1.88.0 is out will get you unblocked...?

@markusl
Copy link
Contributor Author

markusl commented Jan 30, 2021

@skinny85 our CDK Pipelines rollout for container apps has been blocked and waiting for #11815 to be fixed. Now it's fixed but our other pipelines, and I guess most of them, got broken because of the permission error (we try to always update to the latest version).

Since this is a regression in a stable module (codepipeline) I would like to understand why it is not considered worth fixing as a hotfix to retain previous functionality?

Br,
Markus

@skinny85
Copy link
Contributor

skinny85 commented Feb 1, 2021

@markusl this is actually not a regression in the CodePipeline module, as this never properly worked 😜. It is a regression in the Pipelines module, though.

Can you see if the workaround described in this comment can help you on 1.87.0 / 1.87.1 until this fix is released?

NovakGu pushed a commit to NovakGu/aws-cdk that referenced this issue Feb 18, 2021
…iables (aws#12761)

We correctly added permissions for SSM and SecretsManager-type environment variables set on the CodeBuild Project itself,
but we forgot that environment variables could also be set on the CodeBuild CodePipeline action.

Fixes aws#12742

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline-actions bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants