Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Specify files/path when setting CACHE_CONTROL with AWS S3 pipe

Andy Furniss June 4, 2019

I am trying to set up a deployment using the new AWS S3 pipe - https://confluence.atlassian.com/bitbucket/deploy-to-amazon-aws-875304040.html

I'm glad to see that I can set the metadata for files but I can't see how to specify which files I want to set the metadata for. Is this possible? I need different cache-control values for different files. Index.html should be no-cache but my JS and CSS should be cached.

Can I do this with the new S3 pipe?

1 answer

0 votes
Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 26, 2019

Hi @Andy Furniss ! While it's not possible to do in a single pipe run, I think you can do the following: in the first step you deploy all your file that has to be cached, and in the second step, deploy files with no-cache. So basically you need to use the pipe twice. Here is an example:

 
- pipe: atlassian/aws-s3-deploy:0.2.4
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-east-1'
S3_BUCKET: 'my-bucket-name'
LOCAL_PATH: 'build'
CACHE_CONTROL: 'max-age=86400'
EXTRA_ARGS: '--exclude=*.html'

- pipe: atlassian/aws-s3-deploy:0.2.4
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-east-1'
S3_BUCKET: 'my-bucket-name'
LOCAL_PATH: 'build'
CACHE_CONTROL: 'no-cache'
EXTRA_ARGS: '--exclude=*.js --exclude=*.css'

 Note that here we use EXTRA_ARGS pipe parameter to pass the --exclude options to deploy static files and html files separately. 

Andy Furniss June 26, 2019

Thanks @Alexander Zhukov !

In the end, I decided to just do it with the AWS CLI using the cgswong/aws:aws docker image.

I will give your suggestion a try when I get the chance though because I'd rather use the predefined pipes if possible! :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events