NWS Friends demo service module
| examples/hello | ||
| src | ||
| .gitignore | ||
| GNUmakefile | ||
| README.md | ||
Terraform NWS module friends
This is a hello-world example for NWS cloud services.
Terraform install
- Download
terraformbinary for your platform from NWS CDN here - Install with:
sudo mv ./terraform /usr/local/bin/ - Make a symlink to improve user experience:
sudo ln -s /usr/local/bin/terraform /usr/local/bin/tf
Deploying the module
- Init module with
cd examples/hello
tf init
tf plan
- Inspect terraform output and apply changes with:
tf apply -auto-approve
Update deployment
-
Inspect deployed infrastructure with:
tf show -
Update infra, for example, set Vasya's age to 25.
-
Run plan to obtain an infra diff:
tf plan. You should look like below:
Terraform will perform the following actions:
# module.friends.nws_demo_friends.friends will be updated in-place
~ resource "nws_demo_friends" "friends" {
~ friends = [
~ {
~ age = 23 -> 25
name = "Vasya"
# (1 unchanged attribute hidden)
},
# (1 unchanged element hidden)
]
id = "8bd9f27b-8849-43e8-8966-027aba6d4cbe"
name = "Ivan"
}
Plan: 0 to add, 1 to change, 0 to destroy.
-
Apply updated changes with:
tf apply -auto-approve -
Inspect updated infra with:
tf show
# module.friends.nws_demo_friends.friends:
resource "nws_demo_friends" "friends" {
friends = [
{
age = 19
name = "Ann"
sex = "F"
},
{
age = 25 <----- the age was updated
name = "Vasya"
sex = "M"
},
]
id = "8bd9f27b-8849-43e8-8966-027aba6d4cbe"
name = "Ivan"
}
Outputs:
id = "8bd9f27b-8849-43e8-8966-027aba6d4cbe"
name = "Ivan"
Remove deployment
- Destroy deployment with:
tf destroy -auto-approve - Make sure that the infra is empty:
tf show