Knowledge Check - Infrastructure as Code
Test your understanding of the key concepts from Module 2. Select the best answer for each question, then submit to see your results. You need to score at least 60% to pass.
A developer adds a package to the cloud-config file that TaskBoard's API server reads through user_data = base64encode(file("cloud-init/api.yaml")) in its inline volume. After terraform apply, the running server still does not have the package. What is the correct way to get the new configuration onto the server?
The user_data property is immutable and is only allowed to be set on a new volume creation, so cloud-init runs the configuration once at initial provisioning. Rebuilding the server creates a new volume that receives the new cloud-config. A refresh or a reboot does not send new user data to an existing volume.
TaskBoard's worker sits only in the private app LAN. The developer creates this NAT gateway and an SNAT rule with source_subnet = "10.10.1.0/24" and protocol = "ALL". From the worker, curl https://example.com still times out.
resource "ionoscloud_natgateway" "egress" {
datacenter_id = ionoscloud_datacenter.taskboard.id
name = "taskboard-nat"
public_ips = [ionoscloud_ipblock.nat.ips[0]]
lans {
id = ionoscloud_lan.app.id
gateway_ips = ["10.10.1.4"]
}
}
What is missing?
The Managed NAT Gateway does not inject a default route: the routing table of each private VM must point its default route to the gateway, or contain a dedicated route per target. The gateway provides SNAT only and receives the responses to connections the VM initiated, so no DNAT rule is needed. Only private LANs can be connected to the gateway, so making the LAN public is not possible.
A developer attaches a new Network Security Group with no rules to the app-tier NIC of the API server. The NIC sits in the ALB's target LAN, and the ALB uses lb_private_ips = ["10.10.1.6/24"]. Immediately, the ALB health checks fail. Which change restores traffic from the load balancer while keeping the tier closed to other clients?
NSGs deny all traffic that no rule permits, in both directions, so the target NIC needs an ingress rule for the ALB's private address in the target LAN. NSG members are NICs and VMs, not load balancers, so there is no place to attach the group to the ALB itself. Using NSGs in parallel with the NIC-based firewall is not recommended.
A CI pipeline runs terraform apply for TaskBoard's storage tier. It sets only IONOS_TOKEN. The plan contains this resource, and the apply fails with an authentication error for the bucket:
resource "ionoscloud_s3_bucket" "uploads" {
name = "taskboard-uploads-dev-7f3a"
region = "eu-central-3"
}
Which change fixes the pipeline?
IONOS Cloud Object Storage is S3-compatible and authenticates with an Access Key and a Secret Key, not with Cloud API bearer tokens. The provider needs the key pair in IONOS_S3_ACCESS_KEY and IONOS_S3_SECRET_KEY to manage buckets. Object Storage regions use names such as eu-central-3, not data center locations.
TaskBoard's PostgreSQL cluster is defined with ionoscloud_pg_cluster_v2, and the password comes from var.pg_password. After a security review, the developer stores a new password in the secret store and runs terraform plan. The plan shows no changes. What should the developer do?
credentials = {
username = "taskboard"
password = var.pg_password
password_version = "1"
database = "taskboard"
}
The password argument is write-only: it is never stored in Terraform state, so Terraform cannot detect that it changed. Incrementing password_version creates a diff that makes the provider send the new password to the API. Replacing the cluster would destroy the database, and a refresh cannot read a password that the API does not return.