I will use the two steps for 'mainnet-detach', 'mainnet-attach' twice in pipelines.custom.
In the same code(mainnet-detach / mainnet-attach), when the "deploy-mainnet" step is executed for the first time, the variable 'instance_target' is defined as API01, and when the step is executed the second time, the variable 'instance_target' is defined and executed as API02.
How should I modify my code to set the variables?
[i need override values]
definitions:
services:
docker:
memory: 4096
###### deploy Mainnet ######
mainnet-detach: &mainnet-detach
step:
name: Detach mainnet ${target_instance}
image: amazon/aws-cli
runs-on:
- self.hosted
- linux
- ${target_instance}
oidc: true
script:
- export AWS_REGION=${AWS_REGION}
- export AWS_ROLE_ARN=${AWS_ROLE_ARN}
- export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token
- echo $BITBUCKET_STEP_OIDC_TOKEN > $(pwd)/web-identity-token
- aws sts assume-role-with-web-identity --role-arn ${AWS_ROLE_ARN} --role-session-name admin --web-identity-token "$BITBUCKET_STEP_OIDC_TOKEN" --duration-seconds 1000
- status=$(aws elbv2 describe-target-health --target-group-arn ${TARGET_GROUP_ARN} --targets Id=${target_instance_id} --query 'TargetHealthDescriptions[0].TargetHealth.State' --output text)
mainnet-attach: &mainnet-attach
step:
name: Attach mainnet ${target_instance}
image: amazon/aws-cli
runs-on:
- self.hosted
- linux
- ${target_instance}
oidc: true
script:
- export AWS_REGION=${AWS_REGION}
- export AWS_ROLE_ARN=${AWS_ROLE_ARN}
- export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token
- echo $BITBUCKET_STEP_OIDC_TOKEN > $(pwd)/web-identity-token
- aws sts assume-role-with-web-identity --role-arn ${AWS_ROLE_ARN} --role-session-name admin --web-identity-token "$BITBUCKET_STEP_OIDC_TOKEN" --duration-seconds 1000
- status=$(aws elbv2 describe-target-health --target-group-arn ${TARGET_GROUP_ARN} --targets Id=${target_instance_id} --query 'TargetHealthDescriptions[0].TargetHealth.State' --output text)
pipelines:
custom:
deploy-mainnet:
- target_instance=API01
- target_instance_id=${BITBUCKET_VARIABLE_API01}
- <<: *mainnet-detach
- <<: *mainnet-attach
- target_instance=API02
- target_instance_id=${BITBUCKET_VARIABLE_API02}
- <<: *mainnet-detach
- <<: *mainnet-attach