You're building a CI/CD (continuous integration/continuous delivery) pipeline and need to inject sensitive variables into your Terraform run. How can you do this safely?
This is a secure way to inject sensitive variables into your Terraform run, as they will not be stored in any file or source code repository. You can also use environment variables or variable files with encryption to pass sensitive variables to Terraform.
You corrected a typo in a resource name, changing it from aws_s3_bucket.photoes to aws_s3_bucket.photos. You want to update the Terraform state so that the existing resource is recognized under the new name, without destroying and recreating it. Which configuration should you use?
Rationale for Correct Answer: A moved block tells Terraform that an object's address in state has changed (renamed/refactored) and it should move the state from the old address to the new address. This preserves the existing real resource and prevents unnecessary destroy/recreate.
Analysis of Incorrect Options (Distractors):
A: Works but is unnecessarily risky/extra work; moved is the intended refactoring mechanism for renames.
B: Incorrect---refresh-only updates state to match real infrastructure, but it does not remap an object from one address to another.
C: Incorrect---Terraform will treat the new name as a new resource address and the old one as removed unless you explicitly move/rename state.
Key Concept: Refactoring addresses safely using moved blocks (state address migration).
====================
You're building a CI/CD (continuous integration/continuous delivery) pipeline and need to inject sensitive variables into your Terraform run. How can you do this safely?
This is a secure way to inject sensitive variables into your Terraform run, as they will not be stored in any file or source code repository. You can also use environment variables or variable files with encryption to pass sensitive variables to Terraform.
Which of the following is not a benefit of adopting infrastructure as code?
Infrastructure as Code (IaC) provides several benefits, including the ability to version control infrastructure, reuse code, and automate infrastructure management. However, IaC is typically associated with declarative configuration files and does not inherently provide a graphical user interface (GUI). A GUI is a feature that may be provided by specific tools or platforms built on top of IaC principles but is not a direct benefit of IaC itself1.
Reference = The benefits of IaC can be verified from the official HashiCorp documentation on ''What is Infrastructure as Code with Terraform?'' provided by HashiCorp Developer1.
Exhibit:
resource "azurerm_linux_web_app" "app" {
name = "example-app"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
service_plan_id = azurerm_service_plan.plan.id
identity {
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.app.id]
}
}
resource "azurerm_role_assignment" "kv_access" {
scope = azurerm_key_vault.kv.id
role_definition_name = "Key Vault Secrets User"
principal_id = azurerm_user_assigned_identity.app.principal_id
}
Two resource blocks are shown: azurerm_linux_web_app and azurerm_role_assignment. When provisioned, the web app will use the role assignment during creation, so the role assignment must be created first. How do you ensure the azurerm_role_assignment resource is created first?
Rationale for Correct Answer: depends_on explicitly adds a dependency edge in Terraform's graph. By adding depends_on = [azurerm_role_assignment.kv_access] to the web app resource, you force Terraform to create the role assignment first, even if Terraform can't infer the dependency from attribute references.
Analysis of Incorrect Options (Distractors):
B: create_before_destroy is a lifecycle setting relevant to replacement behavior, not initial create ordering between independent resources.
C: File/block order does not control creation order; Terraform uses its dependency graph.
D: count controls quantity, not ordering.
Key Concept: Dependency graph and explicit dependencies via depends_on.
====================
Edward Baker
5 days agoElizabeth Cooper
24 days agoGerald Carter
17 days agoJames Ramirez
12 days agoJessica Flores
3 days agoRichard Allen
21 days agoMark Cook
8 days agoDarrel
1 month agoGearldine
2 months agoDonte
2 months agoLorrie
2 months agoSkye
2 months agoLavonda
3 months agoAudrie
3 months agoDong
3 months agoLigia
3 months agoLynelle
4 months agoElise
4 months ago