Skip to content
Snippets Groups Projects
Commit 5243bd6b authored by marcoemi.poleggi's avatar marcoemi.poleggi
Browse files

Update README.md with task 7-bonus

parent a7da8ea4
No related branches found
No related tags found
No related merge requests found
......@@ -599,6 +599,30 @@ lcl$ ssh -i keys/tf-cloud-init -o IdentitiesOnly=yes $(terraform output -raw ssh
...
```
### Task #7-bonus: a cluster of 2 ###
**Goal:** use advanced HCL features to handle resource arrays.
Now you can provision an instance and have SSH access to it. Let's write a plan variant to provision a cluster of 2 instances.
You shall:
1. Declare a variable or [_local_](https://developer.hashicorp.com/terraform/language/values/locals) `insance_count`.
1. Extend your "app_server" resource with
- a [`count` argument](https://developer.hashicorp.com/terraform/language/meta-arguments/count) using `insance_count`,
- a `name` argument showing the instance count index.
1. Extend the networking-related resources with the count argument plus the index where necessary.
1. Modify your `outputs` to show arrays instead of scalar values.
Once done and your cluster provisioned, the following command should yield a single element of an output array:
```shell
$ terraform output --json instance_public_ip | jq -r '.[0]'
```
The same login should work for both the instances!
### Task #8: further practice with Cloud-init ###
**Goal:** get more acquainted with Cloud-init: change the instance's default
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment