Making changes to CI/CD pipeline for SAM application

0

I am following this tutorial https://catalog.workshops.aws/complete-aws-sam/en-US/module-4-cicd/module-4-cicd-gh/50-sampipeinit It walks you through the steps of building an SAM application with CI/CD pipeline

  1. sam init (using a quick start template - hello world example)
  2. Creat codę commit repo - aws codecommit create-repository --repository-name sam-app
  3. Commit and push all your code
  4. Build a pipeline (sam pipeline init --bootstrap - Two-stage pipeline from template)
  5. sam deploy -t codepipeline.yaml --stack-name sam-app-pipeline --capabilities=CAPABILITY_IAM

I have a question about making changes -

  1. Making changes to the app

            1. I guess I can just update the code and push and in most cases it will just work
    
            2. If I am making breaking changes, I may have to delete the two stages, 
            make a dummy change in the code (a comment) and push to re run the 
            pipeline (By the way, Is this the best way to re run?)
    
  2. Making changes to the CI/CD pipleline

     1. I guess I need to edit the codepipline.yaml (A scary big file with nearly 
     700 lines of CloudFormation code!)
     2. Push
     3 . Run sam deploy -t codepipeline.yaml --stack-name sam-app-pipeline --capabilities=CAPABILITY_IAM
     4. Again, if there are breaking changesI
        I might get errors, in that case I can delete the
      stack for the CI/CD pipeple and try again
    

My questions are about the process of making changes to the setup. 1. When I get into an error state, I am deleting the the stages (the dev and prod stages or the pipeline stages or all of them) and then pushing again and in the case of changes to pipeline, re running sam deploy -t codepipeline.yaml --stack-name sam-app-pipeline --capabilities=CAPABILITY_IAM. Is this right? 2. When I delete all stages (application and CI/CD stages) I am assuming all I am left with is the cloud9 environment and the code commit repo, using which I can rebuild everyone and no other hidden left overs from the old version (deleted stages) would exist anymore. Is this right?

1 Answer
1
Accepted Answer

If you need to modify the CI/CD pipeline itself (e.g., changes to the CodePipeline configuration in the codepipeline.yaml file), your steps are correct. 1)Editing the codepipeline.yaml. 2)Commit and push the changes to CodeCommit. 3) Run sam deploy -t codepipeline.yaml --stack-name sam-app-pipeline --capabilities=CAPABILITY_IAM. If you encounter errors, especially due to breaking changes in the pipeline, deleting the CI/CD stack (sam-app-pipeline) and redeploying is a reasonable approach When you delete the stages or the entire CI/CD pipeline stack, you're correct that you should be left with the Cloud9 environment and the CodeCommit repository. There should not be any hidden leftovers from the old version if you've properly deleted the relevant CloudFormation stacks. Deleting the CI/CD stack (sam-app-pipeline) should remove all associated resources, however, it's always a good practice to verify the AWS Management Console or use AWS CLI commands to ensure that no unexpected resources are left behind Remember to test your pipeline changes in a safe environment before applying them to production, and regularly review AWS resources to avoid any unexpected leftovers.

Hope it clarifies and if does I would appreciate answer to be accepted so that community can benefit for clarity, thanks ;)

profile picture
EXPERT
answered 3 months ago
profile picture
EXPERT
reviewed 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions