-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuildspec-stage.yml
32 lines (30 loc) · 1.45 KB
/
buildspec-stage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
version: 0.2
phases:
install:
commands:
- echo ...
build:
commands:
- echo ...
post_build:
commands:
- REMOTE_TAG=$(cat $CODEBUILD_SRC_DIR_CloudformationArtifact/dockerimage.txt)
- echo Preparing push of $REMOTE_TAG to green $NEXTSTAGE_FARGATE_STACK / $NEXTSTAGE_ALB_STACK
- |
BLUETARGET=$(aws cloudformation describe-stacks --stack-name $NEXTSTAGE_ALB_STACK --query "Stacks[0].Outputs[?OutputKey=='BlueTarget'].OutputValue" --output text)
DOCKER_IMAGE=$(aws cloudformation describe-stacks --stack-name $NEXTSTAGE_FARGATE_STACK --query "Stacks[0].Outputs[?OutputKey=='DockerImage'].OutputValue" --output text)
DOCKER_IMAGE2=$(aws cloudformation describe-stacks --stack-name $NEXTSTAGE_FARGATE_STACK --query "Stacks[0].Outputs[?OutputKey=='DockerImage2'].OutputValue" --output text)
if [ "$BLUETARGET" = "one" ];
then
printf '{"Parameters":{"DockerImage":"%s","DockerImage2":"%s"}}' $REMOTE_TAG $DOCKER_IMAGE2 > fargateconfig2.json
printf '{"Parameters":{"BlueTarget":"two"}}' > albconfig2.json
else
printf '{"Parameters":{"DockerImage":"%s","DockerImage2":"%s"}}' $DOCKER_IMAGE $REMOTE_TAG > fargateconfig2.json
printf '{"Parameters":{"BlueTarget":"one"}}' > albconfig2.json
fi
- cat fargateconfig2.json
- cat albconfig2.json
artifacts:
files:
- fargateconfig2.json
- albconfig2.json