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

Codepipeline cdk v2: Self mutate before synth step #32627

Open
2 tasks
purnasrivatsa96 opened this issue Dec 21, 2024 · 2 comments
Open
2 tasks

Codepipeline cdk v2: Self mutate before synth step #32627

purnasrivatsa96 opened this issue Dec 21, 2024 · 2 comments
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@purnasrivatsa96
Copy link

Describe the feature

Right now, i believe self mutate runs (if we set self Mutation to true in new CodePipeline(...) initialization) after synth step. What if i change commands in synth . And i need pipeline to update before it runs( so it can run the latest synth commands).

Use Case

What if i change commands in synth . And i need pipeline to update before it runs( so it can run the latest synth commands).

Proposed Solution

selfMutateFirst? : boolean

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2

Environment details (OS name and version, etc.)

Deployed to linux

@purnasrivatsa96 purnasrivatsa96 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 21, 2024
@github-actions github-actions bot added the @aws-cdk/aws-codepipeline Related to AWS CodePipeline label Dec 21, 2024
@pahud pahud self-assigned this Dec 23, 2024
@pahud
Copy link
Contributor

pahud commented Dec 23, 2024

This is an interesting idea. I believe for now it would just run the pipeline once and then self-mutate right? I am not sure if we could make it self-mutate first but I get your ideas here. Please help us prioritize with 👍 and we welcome the PRs.

@pahud pahud added p2 effort/medium Medium work item – several days of effort labels Dec 23, 2024
@pahud pahud removed their assignment Dec 23, 2024
@pahud pahud removed the needs-triage This issue or PR still needs to be triaged. label Dec 23, 2024
@purnasrivatsa96
Copy link
Author

purnasrivatsa96 commented Jan 25, 2025

i faced a situation where i felt it would have been nice if this existed.
I have -

export class ServiceCdkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // Create an S3 bucket to store the dist files


    // Create an IAM role for the CodeBuild project with permissions to access the S3 bucket


    // Attach policy to allow CodeBuild to interact with S3
   

    // Attach policy for sts:GetServiceBearerToken


    const pipeline = new CodePipeline(this, "Pipeline", {
      pipelineName: "ServicePipeline",
      selfMutation: true,
      synth: new ShellStep("Synth", {
        input: CodePipelineSource.gitHub(
          "repoName",
          "main"
        ),
        commands: [
          "cd service",
          "make build-server",
          "echo 'testing in Synth step'",
          "cd ..",
          "cd service-cdk",
          "ls -la",
          "npm ci",
          "npm run build",
          "npx cdk synth",
          "mv cdk.out ../",
        ],
        env: {
          NODE_ENV: "production",
        },
      }),
    });

now i updated

make build-server

to expect NODE_ENV and it will throw error if that is not set.
In pipeline , the synth runs first -

Image

followed by updatePipeline which self mutates( and then adds the env var)

Image

So the synth fails since self mutate(which will update pipeline stack to include env in synth step and allow for make to succeed) has not happened yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants