forked from aws-samples/aws-lambda-layer-awscli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
26 lines (25 loc) · 1.22 KB
/
buildspec.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
version: 0.2
env:
variables:
AWS_DEFAULT_REGION: "ap-northeast-1"
AWS_REGION: "ap-northeast-1"
phases:
install:
runtime-versions:
docker: 18
pre_build:
commands:
- rolearn=$(aws sts get-caller-identity | jq -r .Arn | cut -d/ -f1-2 | sed -e 's#assumed-role#role/service-role#g')
- aws sts assume-role --role-arn $rolearn --role-session-name mysession > session.json
- echo "AWS_ACCESS_KEY_ID=$(cat session.json | jq -r .Credentials.AccessKeyId)" > envfile
- echo "AWS_SECRET_ACCESS_KEY=$(cat session.json | jq -r .Credentials.SecretAccessKey)" >> envfile
- echo "AWS_SESSION_TOKEN=$(cat session.json | jq -r .Credentials.SessionToken)" >> envfile
build:
commands:
- echo "touching sam-layer-packaged.yaml and chmod to 777 for samcli user to write in. See http://bit.ly/2Qd5Pxy"
- touch sam-layer-packaged.yaml && chmod 777 sam-layer-packaged.yaml
- make publish-new-version-to-sar
post_build:
commands:
- BUILT_VERSION=$(cat AWSCLI_VERSION)
- aws --region ap-northeast-1 sns publish --topic-arn $SNS_TOPIC_ARN --message "[OK] aws-samples/aws-lambda-layer-awscli version ${BUILT_VERSION} published to SAR us-east-1"