Training slides see https://pages.github.boschdevcloud.com/GS-PJ-TOP98-AI-KNOW/terraform-beginner-workshop/
- login to the AWS account (platform) https://myapplications.microsoft.com/
- Start your cloud9 IDE, check AWS auth. settings
- clone the training repo
git clone https://github.com/frank-bee/terraform-training.git
- Open this Lab docu in seperate browser window
- Open the slides in seperate browser window
- Use the Cloud9 terminal to go to the root of the training repo, where you find the
main.tf
- Run
terraform init
Observe the output - Run
terraform plan
Observe the output
- Try several ways of setting the root variables
- Use a variable to set the attribute
subnet_id
- Introduce a variable
prefix
and use it to prefix the ec2 tag "Name" (with e.g. your name)
- Run
terraform fmt
- Find out about the EC2 / instance attribute which is resposible to enable monitoring of the EC2 (google)
- Enable monitoring and observe the plan.
- Apply the infrastructure with a
terraform apply
- Check the result in the AWS console (region Ireland!)
- Change something in the code, e.g. enabling /disabling ec2 monitoring (attribute
monitoring
)
What do you expect runningterraform plan
? Do it - Apply the changes with a
terraform apply --auto-approve
- Destroy the infrastructure with a
terraform destroy
- What do you expect running
terraform plan
? Do it - Recreate the infrastructure
- Add a terraform output for the URL of your wordpress site to your stack (typically in a file
output.tf
)
Hint: Make use of the attributepublic_dns
of the instance - Apply the change
- Try the command
terraform output
- Can you see the wordpress site in your browser? Quiz: why not?
- Create a SG with this module
Set the following attributes: name, description, vpc_id, cidr_blocks.
Use the internet CIDR block0.0.0.0/0
- or even better your own IP / Bosch IP range - Reference a suitable attribute in your
aws_network_interface
:
resource "aws_network_interface" "wpress" {
subnet_id = "subnet-0f59ce43a926f6179"
security_groups = ...
- Apply the changes to your stack
- Does your wordpress appear in the browser now?
- Run
terraform graph
- Copy the output to https://dreampuf.github.io/GraphvizOnline/
- Have a look at the dependencies
- Refactor the "hardcoded" subnet_id
- Use https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet
Hint: Filter
- Create a branch in in our infrastrastructure repo
- Instantiate the terraform-aws-dummy module in the platform dev stack
Hint: See how to reference the latest module version here - Open a pull request and observe the terraform plan
- Add Frank as reviewer