Exercise #1
New Directory
Create a new directory named modules, and inside it a sub-directory named edgeworkers. So you end up with ./modules/edgeworkers.
New Module
In your ./modules/edgeworkers create all the necessary *.tf files to create a new EdgeWorker ID. Make sure that the name
, group_id
and resource_tier_id
are parameters that can be set by the root module.
New File
Back in your root directory create a new edgeworkers.tf file and add the necessary Terraform code to call the EdgeWorkers module.
Plan
Run a terraform plan
. Why do you need to run a terraform init
?
Init
After running the terraform init
try to run the terrform plan
again. What happened?
Hint: remember to define the akamai
provider in the child modules.
Plan/Apply
After defining the provider in your child module run terraform plan
and terraform apply
.
Commit
Commit your changes and push them to GitHub.
Exercise #2
Configure
In your property.tf you should have the rule tree defined in a data.akamai_property_rules_builder
. Convert this data source to a Terraform module instead.
- Create a new directory inside the modules directory and name it rules. So ./modules/rules
- Add all the necessary child module *.tf files inside this directory.
Hint: remember to create the variables.tf with any of the parameters needed for your rule tree. If you've been following along you should have 2 parameters in the rule tree: ab_test
for the origin selection and the akamai_cp_code.my_cp_code.id
. These 2 values will be arguments when you call the module.
Update
Use your new child module in you property.tf to build the rule tree and update the akamai_property
accordingly.
Hint: remember that the akamai_property
resource requires the rule_format
and rules
argument which should be updated with the expression to reference the newly created module. Also keep in mind that you need to define these values as outputs in the child module.
Plan/Apply
Run Terraform.
Commit
Commit your changes and push them to GitHub.