- The steps below were successfully tested using:
- Terraform (0.14.4)
- Go to url
- Create a file or override the location in aws/provider.tf
[default]
aws_access_key_id = XXXX
aws_secret_access_key = XXXX
- In aws/vars.tf the private key and the public keys are assumed to be in the standard location
variable "public_key_path" {
default = "~/.ssh/id_rsa.pub"
}
variable "private_key_path" {
default = "~/.ssh/id_rsa"
}
- Overide the tag used in vars.tf
variable "tags" {
type = map
default = { Name = "testing-noctua-app-stack" }
}
Note: Terraform creates some folders and files to maintain the state. Use ls -a aws
# This will install the aws provider.
terraform -chdir=aws init
# Validate the config
terraform -chdir=aws validate
# View what is going to be created. The plan.
terraform -chdir=aws plan
# This will create the vpc, security group and the instance
terraform -chdir=aws apply
# To view the outputs
terraform -chdir=aws output
#To view what was deployed:
terraform -chdir=aws show
export HOST=`terraform -chdir=aws output -raw public_ip`
export PRIVATE_KEY=`terraform -chdir=aws output -raw private_key_path`
ssh -o StrictHostKeyChecking=no -i $PRIVATE_KEY ubuntu@$HOST
docker ps
which docker-compose
Assuming you have built the docker images and pushed them to dockerhub using build_images and push_images playbooks as explained in this document
export HOST=`terraform -chdir=aws output -raw public_ip`
export PRIVATE_KEY=`terraform -chdir=aws output -raw private_key_path`
ansible-playbook -e "stage_dir=/home/ubuntu/stage_dir" -e "host=$HOST" --private-key $PRIVATE_KEY -u ubuntu -i "$HOST," stage.yaml
ssh -o StrictHostKeyChecking=no -i $PRIVATE_KEY ubuntu@$HOST
docker-compose -f stage_dir/docker-compose-golr.yaml up -d
#When the stack is up you can access it from broswer on port 8080 and using aws instance's public ip.
terraform -chdir=aws destroy