File tree Expand file tree Collapse file tree 4 files changed +113
-2
lines changed Expand file tree Collapse file tree 4 files changed +113
-2
lines changed Original file line number Diff line number Diff line change
1
+ FROM atlassian/pipelines-awscli:1.16.98
2
+
3
+ COPY pipe /usr/bin/
4
+
5
+ ENTRYPOINT ["/usr/bin/pipe.sh" ]
Original file line number Diff line number Diff line change 1
- # aws-cloudfront-create-invalidation
2
- Bitbucket Pipe
1
+ # Bitbucket Pipelines Pipe: AWS Cloudfront Create Invalidation
2
+
3
+ Pipe to deploy to Amazon Cloudfront create-invalidation
4
+
5
+ ## YAML Definition
6
+
7
+ Add the following snippet to the script section of your ` bitbucket-pipelines.yml ` file:
8
+
9
+ ``` yaml
10
+ - pipe : rudijs/aws-cloudfront-create-invlidation:1.0.0
11
+ variables :
12
+ AWS_ACCESS_KEY_ID : " <string>"
13
+ AWS_SECRET_ACCESS_KEY : " <string>"
14
+ DISTRIBUTION_ID : " <string>"
15
+ ` ` `
16
+
17
+ ## Variables
18
+
19
+ | Variable | Usage |
20
+ | -------------------------- | -------------------------- |
21
+ | AWS_ACCESS_KEY_ID (\* ) | AWS access key. |
22
+ | AWS_SECRET_ACCESS_KEY (\* ) | AWS secret key. |
23
+ | DISTRIBUTION_ID (\* ) | Cloudfront Distribution ID |
24
+
25
+ _(\* ) = required variable._
26
+
27
+ ## Basic example:
28
+
29
+ ` ` ` yaml
30
+ script :
31
+ - pipe : atlassian/aws-s3-deploy:0.2.4
32
+ variables :
33
+ AWS_ACCESS_KEY_ID : $AWS_ACCESS_KEY_ID
34
+ AWS_SECRET_ACCESS_KEY : $AWS_SECRET_ACCESS_KEY
35
+ DISTRIBUTION_ID : $DISTRIBUTION_ID
36
+ ` ` `
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Begin Standard 'imports'
4
+ set -e
5
+ set -o pipefail
6
+
7
+ gray=" \\ e[37m"
8
+ blue=" \\ e[36m"
9
+ red=" \\ e[31m"
10
+ green=" \\ e[32m"
11
+ reset=" \\ e[0m"
12
+
13
+ info () { echo -e " ${blue} INFO: $* ${reset} " ; }
14
+ error () { echo -e " ${red} ERROR: $* ${reset} " ; }
15
+ debug () {
16
+ if [[ " ${DEBUG} " == " true" ]]; then
17
+ echo -e " ${gray} DEBUG: $* ${reset} " ;
18
+ fi
19
+ }
20
+
21
+ success () { echo -e " ${green} ✔ $* ${reset} " ; }
22
+ fail () { echo -e " ${red} ✖ $* ${reset} " ; exit 1; }
23
+
24
+ # # Enable debug mode.
25
+ enable_debug () {
26
+ aws_debug_args=" "
27
+ if [[ " ${DEBUG} " == " true" ]]; then
28
+ info " Enabling debug mode."
29
+ set -x
30
+ aws_debug_args=" --debug"
31
+ fi
32
+ }
33
+
34
+ # Execute a command, saving its output and exit status code, and echoing its output upon completion.
35
+ # Globals set:
36
+ # status: Exit status of the command that was executed.
37
+ # output: Output generated from the command.
38
+ #
39
+ run () {
40
+ echo " $@ "
41
+ set +e
42
+ " $@ " 2>&1
43
+ status=$?
44
+ set -e
45
+ }
46
+
47
+ # End standard 'imports'
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ #
3
+ # Cloudfront create invalidation
4
+ #
5
+ # Required globals:
6
+ # AWS_ACCESS_KEY_ID
7
+ # AWS_SECRET_ACCESS_KEY
8
+ # DISTRIBUTION_ID
9
+
10
+ source " $( dirname " $0 " ) /common.sh"
11
+
12
+ # mandatory parameters
13
+ AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:? ' AWS_ACCESS_KEY_ID variable missing.' }
14
+ AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:? ' AWS_SECRET_ACCESS_KEY variable missing.' }
15
+ DISTRIBUTION_ID=${DISTRIBUTION_ID:? ' DISTRIBUTION_ID variable missing.' }
16
+
17
+ info " Starting Cloudfront create invalidation..."
18
+
19
+ run aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths ' /*'
20
+
21
+ if [[ " ${status} " -eq 0 ]]; then
22
+ success " Create Invalidation successful."
23
+ else
24
+ fail " Create Invalidation failed."
25
+ fi
You can’t perform that action at this time.
0 commit comments