-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spring Boot in AWS Elastic Beanstalk with AWS Cloudformation
- Loading branch information
1 parent
b2982af
commit 818946e
Showing
26 changed files
with
1,742 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Testing the code | ||
|
||
## Requirements | ||
|
||
- [An AWS Account](https://aws.amazon.com/account/) | ||
- An IAM user with [programmatic access](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) | ||
- The AWS CLI with a [profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) configured | ||
- [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) (on Windows you will need [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10)) | ||
|
||
## Configuration | ||
|
||
cd eb-springboot-infra | ||
# Update the file `vars/common-vars.asb.yml` with appropriate values | ||
ansible-playbook init/main.asb.yml --check -v | ||
ansible-playbook init/main.asb.yml | ||
|
||
ansible-playbook infra/main.asb.yml --check -v | ||
ansible-playbook infra/main.asb.yml | ||
|
||
cd ../eb-springboot-app | ||
# Update the file `vars/common-vars.asb.yml` with appropriate values | ||
git init | ||
git remote add origin codecommit::us-east-1://spikeseed-labs@eb-springboot-app | ||
git add -A | ||
git commit -m "Demo application" | ||
git push origin master | ||
|
||
cd ../eb-springboot-infra | ||
ansible-playbook cicd/main.asb.yml --check -v | ||
ansible-playbook cicd/main.asb.yml | ||
|
||
# Wait for the Elastic BeanStalk to be created, then: | ||
|
||
curl -i -H "x-com-token: 0123456789" https://<aws_accounts.labs.backend_dns>/api/v1/hello # FQDN configured in common-vars.asb.yml | ||
|
||
|
||
### Cleanup | ||
|
||
1. Remove the stacks | ||
2. Remove the CodeCommit repositories | ||
4. Remove the S3 Buckets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
*.iml | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
|
||
vars: | ||
pbk_account: "{{ aws_accounts.labs }}" | ||
pbk_account_name: "{{ pbk_account.account_name }}" | ||
pbk_account_code: "{{ pbk_account.account_code }}" | ||
pbk_account_env: "{{ pbk_account.environment }}" | ||
|
||
vars_files: | ||
- vars/common-vars.asb.yml | ||
|
||
tasks: | ||
|
||
- name: "Deploy CloudFormation stack {{ local_stack_name }}" | ||
amazon.aws.cloudformation: | ||
stack_name: "{{ local_stack_name }}" | ||
state: present | ||
region: "{{ local_region_name }}" | ||
profile: "{{ pbk_account_name }}" | ||
template: "templates/backend.cfn.yml" | ||
tags: "{{ local_aws_tags }}" | ||
template_parameters: | ||
AccountCode: "{{ pbk_account_code }}" | ||
RegionCode: "{{ local_region_code }}" | ||
Environment: "{{ pbk_account_env }}" | ||
Application: "{{ application }}" | ||
ServerType: backend | ||
SsmVpcIdKey: "{{ ssm_vpc_id_key }}" | ||
SsmPublicSubnetsKey: "{{ ssm_web_public_subnets_id_key }}" | ||
SsmPrivateSubnetsKey: "{{ ssm_app_private_subnets_id_key }}" | ||
PublicHostedZoneId: "{{ public_hosted_zone_id }}" | ||
AlbHostedZoneId: "{{ aws_config[local_region_name].alb_hz_id }}" | ||
BackendDns: "{{ pbk_account.backend_dns }}" | ||
BackendCertificateArn: "{{ pbk_account.backend_certificate_arn }}" | ||
BackendSolutionStackName: "{{ pbk_account.backend_eb_stack_name }}" | ||
SsmBackendS3BucketNameKey: "{{ ssm_assets_bucket_name_key }}" | ||
SsmBackendArchiveS3KeyKey: "{{ ssm_website_eb_app_archive_s3_key_key }}" | ||
BackendInstanceType: "{{ pbk_account.backend_instance_type }}" | ||
AppMinSize: "{{ pbk_account.backend_asg_min_size }}" | ||
AppMaxSize: "{{ pbk_account.backend_asg_max_size }}" | ||
SsmLogsBucketNameKey: "{{ ssm_logs_bucket_name_key }}" | ||
vars: | ||
local_region_name: "{{ default_aws_region }}" | ||
local_region_code: "{{ default_aws_region_code }}" | ||
local_stack_name: "{{ pbk_account_code }}-{{ local_region_code }}-{{ application }}" | ||
local_aws_tags: | ||
Application: "{{ application }}" | ||
Environment: "{{ pbk_account_env }}" | ||
Env: "{{ pbk_account_env }}" | ||
Name: "{{ local_stack_name }}" | ||
ServerType: backend | ||
Service: backend |
Oops, something went wrong.