This repository contains a simple AWS CloudFormation stack that creates an Ubuntu20.04 EC2 instance with an associated security group and a Tomcat service fully configured. It also contains a AWS CodeDeploy yml and associated scripts to install and compile a tiny java app inside tomcat.
-
tomcat.yml: This is the CloudFormation template that defines the resources for the stack. It creates an EC2 instance and a security group. It also installs and configures Tomcat, along with its dependencies such as Java. -
deploy.sh: This script deploys the CloudFormation stack using the AWS CLI. It assumes that the AWS CLI is installed and configured, and that the stack name is 'Tomcat10'. -
delete.sh: This script deletes the CloudFormation stack using the AWS CLI. It also assumes that the AWS CLI is installed and configured, and that the stack name is 'Tomcat10'. -
appspec.yml: This is the CodeDeploy pipeline. -
CodeployTomcat: This is the CloudFormation template that contains the same services liketomcat.ymlbut adding the creation of a CodeDeploy application and group using the stack name a a filter. -
launchApp.sh: This script launch the applicacion defined atCodeployTomcatusing this github repo as a source.
-
Make sure you have the AWS CLI installed and configured with a profile named 'default'.
-
To deploy the stack inside
tomcat.ymlrun thedeploy.shscript after ensure that the aws command is targetting the yml:bash deployStack.sh
-
To delete the stack, run the
delete.shscript:bash deleteStack.sh
-
Log into your AWS web client and create a new CodeDeploy application targeting your new EC2 instance that was created after the initial stack finished.
EC2 name: Tomcat10Stack name: Tomcat10 -
Wait until the application finish and check your endpoint.
Endpoint: /hola2 -
If you are using
CodeployTomcatchange your role credential inside CodeDeployDeploymentGroup service calledServiceRoleArn.To find your role credential go to your iam section in your aws account and copy your iam code that have privilegies to run CodeDeploy.
-
Run
launchApp.shafter the stack finish to run the CodeDeploy installation.bash launchApp.sh
Please note that the stack name 'Tomcat10' is hardcoded in the scripts. If you want to use a different stack name, you will need to modify the scripts accordingly. The endpoint is hardcored in the pipeline scripts.
- AWS CLI
- AWS account with permissions to create EC2 instances, security groups and CodeDeploy applications.
- Bash shell to run the scripts
Please use this stack at your own risk. Always check the resources that are being created and ensure that they comply with your security and cost requirements.