Hands-on exercises “Cloud Storage with upload”
Goal
Build on the first bucket, upload a local file, and optionally migrate Terraform state to a remote backend. The upload resource and backend syntax are provider-specific, so continue with the provider selected in Hands-on 2.
Preparation
- Keep the same provider, credentials, and project folder from Hands-on 2.
- Add a small local file such as
hello.txtto the project directory. - Read the selected provider’s object-upload resource and backend documentation.
- Confirm that the state bucket is separate from the bucket used for workshop files when the provider requires a dedicated state container.
Steps
- Copy the bucket configuration and give the second bucket a unique name, or extend the existing bucket only if the provider supports the intended upload workflow.
- Add the provider-specific object-upload resource and upload
hello.txt. - Run
terraform fmt,terraform validate, andterraform plan. Confirm that Terraform proposes the bucket object and does not replace the bucket unexpectedly. - Apply and verify the uploaded object in the provider console or CLI.
- If the workshop environment supports remote state, create or select a dedicated state bucket first. Add the backend configuration with literal, provider-specific settings; backend blocks cannot use Terraform variables.
- Run
terraform init -migrate-state, review the migration prompt, and verify that a new plan still reports no unexpected changes.
Remote state is an optional extension, not a prerequisite for the upload exercise. Never store the state bucket inside the state that it is meant to hold.