CodePipeline unable to update pipelineType or triggers using aws-cli
Hi there,
I am having some difficulty in upgrading an existing CodePipeline using AWSCLI.
Specifically I want to set the Pipeline Type to V2 and configure git triggers to watch new tags beginning with v*
.
I have done this manually through the AWS console, but I want to automate this as part of my devops.
The issue
Despite the documentation for awscli update-pipeline and API UpdatePipeline clearly demonstrating the use of pipelineType
and triggers
objects, I get the following error when attempting to set these
# $CODEPIPELINE_JSON is modified input of `aws codepipeline get-pipeline` command, see below aws codepipeline update-pipeline --profile $AWS_PROFILE --cli-input-json "$CODEPIPELINE_JSON" --no-cli-pager Parameter validation failed: Unknown parameter in pipeline: "pipelineType", must be one of: name, roleArn, artifactStore, artifactStores, stages, version Unknown parameter in pipeline: "triggers", must be one of: name, roleArn, artifactStore, artifactStores, stages, version
Can anyone advise where I am going wrong, or any other way to achieve this progmatically?
At the time of writing, CloudFormation doesn't support setting the pipelineType
or triggers
for AWS::CodePipeline::Pipeline either, and most importantly, whenever I update the cloudformation template, the CodePipeline gets reverted back to V1 and I lose the ability to watch for new tags. Not great in a prod environment.
Below is a redacted copy of $CODEPIPELINE_JSON
with the pertinent values included
{ "pipeline": { "name": "my-prod-pipeline-name", "roleArn": "arn:aws:iam::XXXXXXXXXXXX:role/my-prod-pipeline-role", "artifactStore": { "type": "S3", "location": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, "stages": [ { /* snip ...*/ } ], "version": 19, "pipelineType": "V2", "triggers": [ { "providerType": "CodeStarSourceConnection", "gitConfiguration": { "sourceActionName": "GitHubSourceActionForProd", "push": [ { "tags": { "includes": [ "v*" ], "excludes": [] } } ] } } ] } }
and i'm using a shell script akin to this, to perform the update by modifying the JSON structure of the existing pipepline:
#!/usr/bin/env bash CODEPIPELINE_NAME="my-prod-pipeline-name" AWS_PROFILE="my-profile" # Retrieve existing codepipeline CODEPIPELINE_JSON=$(aws codepipeline get-pipeline --name $CODEPIPELINE_NAME --profile $AWS_PROFILE --no-cli-pager) # Remove the "metadata" section from $CODEPIPELINE_JSON CODEPIPELINE_JSON=$(echo "$CODEPIPELINE_JSON" | jq 'del(.metadata)') # Add the pipelineType and triggers to existing JSON NEW_JSON='{ "pipelineType": "V2", "triggers": [ { "providerType": "CodeStarSourceConnection", "gitConfiguration": { "sourceActionName": "GitHubSourceActionForProd", "push": [ { "tags": { "includes": ["v*"], "excludes": [] } } ] } } ] }' # Add the new JSON to the pipeline object CODEPIPELINE_JSON=$(echo "$CODEPIPELINE_JSON" | jq --argjson newJson "$NEW_JSON" '.pipeline += $newJson') # Output JSON for debugging purposes echo "$CODEPIPELINE_JSON" # Perform the update aws codepipeline update-pipeline --profile $AWS_PROFILE --cli-input-json "$CODEPIPELINE_JSON" --no-cli-pager
- Mais recentes
- Mais votos
- Mais comentários
Conteúdo relevante
- AWS OFICIALAtualizada há 4 meses
- AWS OFICIALAtualizada há 2 meses
- AWS OFICIALAtualizada há 2 anos