how to change the source branch of the AWS codepipeline through aws lambda(python)?

372 views Asked by At

Using AWS code pipeline, here in source i configured a branch of a repo(using bitbucket repo) and ill release the pipeline it will build and deploy. I used to change the source branch manually by editing the pipeline. Now i want to do this through aws lambda(python). Facing trouble with "client.update_pipeline". is this is the right way or what should i do? https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/codepipeline.html#CodePipeline.Client.update_pipeline https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdatePipeline.html

I want to change the source branch of the pipeline from same repo(bitbucket) via aws lambda(python)

1

There are 1 answers

0
Chuong Nguyen On

Yes, you can use boto3 for Python in Lambda to update the source branch of your pipeline:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/codepipeline.html

response = client.update_pipeline(
    name=your_pipeline,
    stage_variables={
        'BranchName': {
            'variable_value': new_branch
        }
    }
)