3

I'm using aws-cdk for my architecture and I need one last piece to the puzzle. Is it possible to move files from S3 to specific directories on the EC2 instance?

I have my .env file and nginx config files in an S3 bucket and once the update has rolled out using CodePipeline/CodeDeploy I want to move the files into their place. I don't want to manage these files on GitHub or by having to SSH into the instance.

// appspec.yml

files:
  - source: /
    destination: /path/to/webserverdir

Can I use S3 as a source?

4
  • Copying the S3 content can be part of the CodeDeploy script ran by the CodeDeploy agent. What is the problem, what is not clear or working? Commented Oct 10, 2021 at 12:46
  • How? I cannot figure out how to copy files over to the EC2 instance. Commented Oct 10, 2021 at 21:32
  • What is your appspec.yml that tries to copy the files? What errors do you get? Commented Oct 10, 2021 at 21:52
  • @Marcin Updated original question with contents. Commented Oct 10, 2021 at 21:55

1 Answer 1

4

Can I use S3 as a source?

Sadly, you can't. You have to write bash/powershell script which is going to use AWS CLI to perform the copy from S3 to the instance. Then you invoke the script as part of your appspec.yml. In addition to this, your instances will need to have an instance role with permissions to S3.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I ended going this route and it works fine after allowing permissions as you stated.
@JuanRangel No problem. Glad it worked out :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.