5. Remote State Management Flashcards
1
Q
Module Sources in Terraform
The source argument in a module block tells Terraform where to find the source code for the desired child module.
- Local paths
- Terraform Registry
- GitHub
- Bitbucket
- Generic Git, Mercurial repositories
- HTTP URLs
- S3 buckets
- GCS bucket
A
2
Q
Git Module Source
- Arbitrary Git repositories can be used by prefixing the address with the special git:: prefix.
- After this prefix, any valid Git URL can be specified to select one of the protocols supported by Git.
- source = “git::https://example.com/vpc.git”
- By default, Terraform will clone and use the default branch (referenced by HEAD) in the selected repository. You can override this using the ref argument.
- source = “git::https://example.com/vpc.git?ref=v1.2.0”
A
3
Q
Terraform & GitIgnore
Depending on the environment, it is recommended to avoid committing certain files to Git.
- .terraform: this file will be recreated when Terraform init is run
- terraform.tfvars: Likely to contain sensitive data like usernames/passwords and secrets
- terraform.tfstate: Should be stored in the remote side
- crash.log: If Terraform crashes, the logs are stored to a file named crash.log
A
4
Q
Remote State Management
- Terraform supports various types of remote backends which can be used to store state data.
- Depending on remote backends that are being used, there can be various features.
- Standard BackEnd Type: State Storage and Locking
- Enhanced BackEnd Type: All features of Standard + Remote Management
A
5
Q
Terraform State Management
There are multiple sub-commands that can be used with terraform state, these include:
A
6
Q
Terraform Import
- Terraform is able to import existing infrastructure. This allows you to take resources you’ve created by some other means and bring it under Terraform management.
- The current implementation of Terraform import can only import resources into the state. It does not generate configuration. A future version of Terraform will also generate configuration.
- Because of this, prior to running terraform import it is necessary to write manually a resource configuration block for the resource, to which the imported object will be mapped.
A