Skip to content

Adding inline policy to PDKPipeline #188

Answered by mteichtahl
mteichtahl asked this question in Q&A
Discussion options

You must be logged in to vote

CDK pipelines only generates the pipeline resources (including the associated roles) on app.synth().

Therefore, if you want to update a policy you need to do this after pipelineStack.pipeline.buildPipeline(); but before app.synth(). For example

 pipelineStack.pipeline.addStage(devStage);

  pipelineStack.pipeline.buildPipeline(); 

  pipelineStack.pipeline.synthProject.addToRolePolicy(
    new PolicyStatement({
      sid: "AllowGetManagedPrfixList",
      effect: Effect.ALLOW,
      resources: pipelineStack.node.tryGetContext("applPrefixLists"),
      actions: ["ec2:GetManagedPrefixListEntries"],
    })
  );
  app.synth();

Replies: 1 comment

Comment options

mteichtahl
Oct 7, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by cogwirrel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant