Spring Cloud Server on ElasticBeanstalk
Copy or rename the example ElasticBeanstalk config file:
$ cp .ebextensions.config.example .ebextensions.config
Replace the content keys in the newly created file. I base64-encoded some of the content to make
sure the whitespaces are conserved properly. You can base64 files and strings from the command line like this:
File: $ base64 -w 0 <file>
String: $ echo "Hello Config Server" | base64 -w 0
The file contains 4 sections:
host git-codecommit.*.amazonaws.com
User APXXXXX6CXYYYIQXXXXX
Open IAM in your AWS console, create a user and assign it an SSH-key. Use the SSH key ID as the username. Make sure your
AWS user has to right permissions to access the repo. You can do that by assigning a policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:BatchGetRepositories",
"codecommit:Get*",
"codecommit:GitPull",
"codecommit:List*"
],
"Resource": "<arn_of_your_codecommit_repo>"
}
]
}
Add the key you uploaded to for your IAM user before and add it in the corresponsing places in the config file.
You can either disable the host key checks, which is absolutely not recommended or add the Amazons’s CodeCommit host to
the known_hosts
file. Amazon publishes their fingerprints here,
so you can compare if they match:
ssh-keygen -lf /dev/stdin <<< `ssh-keyscan -t rsa git-codecommit.us-west-2.amazonaws.com`
If everything’s ok, fetch the key with $ ssh-keyscan -t rsa git-codecommit.us-west-2.amazonaws.com
and add it to the
known_hosts content section in the config file.
Copy the example bootstrap file and update the url to your repository. I prefer to set the encryption key via an ENV
variable, but it’s also possible to set it in the config file.
After configuring everything a $ mvn clean package
creates a so called deploy package in the target folder, which is
a zip file containing everything EB needs to get going: