Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lab-Terraform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LSDS
Teaching
Bachelor
Cloud-and-Deployment
Lab-Terraform
Commits
5243bd6b
Commit
5243bd6b
authored
7 months ago
by
marcoemi.poleggi
Browse files
Options
Downloads
Patches
Plain Diff
Update README.md with task 7-bonus
parent
a7da8ea4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SwitchEngines/README.md
+24
-0
24 additions, 0 deletions
SwitchEngines/README.md
with
24 additions
and
0 deletions
SwitchEngines/README.md
+
24
−
0
View file @
5243bd6b
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment