Knowledge Check - Programmatic Foundations
Test your understanding of the key concepts from Module 1. Select the best answer for each question, then submit to see your results. You need to score at least 60% to pass.
A developer's script sends POST https://api.ionos.com/cloudapi/v6/datacenters and receives 202 Accepted. The response body shows "state": "BUSY". The next step of the script creates a server in the new data center. What should the script do between the two calls?
For the API v6, resources are created asynchronously: the 202 only means the request was accepted, and the Location header holds the URL to poll until the request reaches DONE (or FAILED). A fixed sleep guesses the duration and hides provisioning errors. Retrying the POST would create more data centers instead of checking the first one.
A CI job mints an access token with GET https://api.ionos.com/auth/v1/tokens/generate using an Authorization: Basic header. After the account enforces 2-Factor Authentication, the job can no longer get a token. Which change fixes the job?
Accounts with 2-Factor Authentication enabled or forced must use bearer token authentication, and the generate endpoint accepts a secure token in the Authorization: Bearer header. The X-Contract-Number header selects a contract; it does not bypass 2-Factor Authentication. The endpoint is a GET, and changing the method or ttl does not change the authentication rule.
A developer writes a generator that returns every server in a large data center. Which line correctly completes the loop?
def list_all(session, url):
params = {"offset": 0, "limit": 100}
while url:
page = session.get(url, params=params).json()
yield from page.get("items", [])
# missing line
params = None
Collection responses include _links.next only when offset + limit is less than the total number of elements, so the loop stops by itself on the last page, and the next URL already carries offset and limit. Re-requesting page["href"] or the same url loops forever. Increasing offset by 1 would skip only one element per page and return overlapping results.
TaskBoard's Terraform configuration contains this resource. A developer changes location from de/txl to de/fra and runs terraform plan.
resource "ionoscloud_datacenter" "taskboard" {
name = "taskboard-dev"
location = "de/txl"
}
What does the plan show?
The location argument of ionoscloud_datacenter is immutable, so Terraform can only replace the data center, which also removes everything inside it. Review every -/+ line in a plan for this reason. The ionoscloud_location data source looks up location details; it is not required to set location.
A server was created by hand with ionosctl in Unit 1.1. A developer wants to bring it under Terraform management as ionoscloud_server.api and generate its configuration. Which approach is correct?
The ionoscloud_server resource is imported with the data center ID and the server ID together, and -generate-config-out writes a matching resource block for you to review. A server ID alone is not the documented import ID. Editing the state file by hand or declaring a data source does not make Terraform manage the resource.