0
0
Terraformcloud~10 mins

Secret management integration (Vault, Secrets Manager) in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a Vault provider in Terraform.

Terraform
provider "vault" {
  address = "[1]"
}
Drag options to blanks, or click blank then click option'
A"http://127.0.0.1:8500"
B"https://secretsmanager.aws.com"
C"https://vault.example.com"
D"http://localhost:8200"
Attempts:
3 left
💡 Hint
Common Mistakes
Using AWS Secrets Manager URL instead of Vault URL.
Using incorrect port numbers.
Leaving the address blank.
2fill in blank
medium

Complete the code to read a secret from Vault using Terraform data source.

Terraform
data "vault_generic_secret" "example" {
  path = "[1]"
}
Drag options to blanks, or click blank then click option'
A"secret/data/myapp/config"
B"aws/secretsmanager/myapp"
C"kv/myapp/config"
D"secret/myapp/config"
Attempts:
3 left
💡 Hint
Common Mistakes
Using AWS Secrets Manager path format.
Using KV v1 path format without /data/.
Incorrect secret engine path.
3fill in blank
hard

Fix the error in the Terraform code to retrieve AWS Secrets Manager secret.

Terraform
data "aws_secretsmanager_secret_version" "example" {
  secret_id = [1]
}
Drag options to blanks, or click blank then click option'
A"example-secret-id"
B"aws_secretsmanager_secret.example.id"
Caws_secretsmanager_secret.example.id
Dexample-secret-id
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the secret ID string.
Using resource references incorrectly.
Using variable names without quotes.
4fill in blank
hard

Fill both blanks to define a Vault secret resource with a dynamic key and value.

Terraform
resource "vault_generic_secret" "example" {
  path = "secret/data/[1]"
  data_json = jsonencode({
    [2] = "mysecretvalue"
  })
}
Drag options to blanks, or click blank then click option'
Amyapp
Bconfig
Cpassword
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect path segments.
Using keys that don't match secret content.
Confusing path and key names.
5fill in blank
hard

Fill all three blanks to output the secret value from Vault data source in Terraform.

Terraform
output "db_password" {
  value = data.vault_generic_secret.[1].data.[2]["[3]"]
}
Drag options to blanks, or click blank then click option'
Aexample
Bdata
Cpassword
Dsecret
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong data source name.
Accessing secret keys incorrectly.
Confusing Vault KV v1 and v2 data structure.