Infrastructure as Code (TF) Flashcards

1
Q

How does leveraging modules to achieve code reusability and maintainability?

A
  • encapsulate reusable components, such as networking setups and application stacks
  • By abstracting these modules, it can reduce duplication and improve code consistency across environments
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do workspaces help achieve code reusability and maintainability?

A
  • Workspaces enables management of multiple instances of our infrastructure with minimal duplicated code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How did you address state-related challenges?

A
  1. Use a remote backend
  2. Use state locking (e.g. Dynamo DB)
  3. For large state files, you can us “split state” approach, breaking down the state into smaller, manageable components while maintaining cross-references
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Discuss strategies to integrate secrets management tools

A
  • Used AWS Secrets Manager and Parameter store
  • Automatically rotate secrets
  • Mark secrets as sensitive in Terraform
  • Secrets injected at runtime, not queried over the network
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe a scenario where you’ve used Terraform’s service-specific providers, like the AWS ECS provider, to define application-level configurations alongside infrastructure provisioning?

A
  • In a containerized application deployment, we used the AWS ECS provider within Terraform to define the application’s task definitions, services, and load balancers alongside the infrastructure components.
  • This integrated approach ensured that both infrastructure and application configuration were versioned and deployed together, minimizing inconsistencies.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you use Infrastructure as Code (IaC) validation and policy enforcement?

A
  1. enforce compliance and naming conventions
  2. validate security group configurations
  3. catch errors before deployment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When designing a Terraform project structure, what are the key considerations you take into account to ensure maintainability and scalability?

A
  • prioritize modularization to promote reusability and easier maintenance.
  • each module encapsulates a specific piece of infrastructure
  • use variables and outputs to abstract configuration details and create clear interfaces for module usage
  • structure the project with directories for modules, environments, and global configurations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you structure your project to effectively manage environment-specific configurations while minimizing duplication and ensuring consistent infrastructure provisioning across environments?

A
  • adopt a flexible approach to manage environments
  • use workspaces or separate directories for each environment
  • allow isolated state files and configuration files per environment if using directories
  • environment-specific variables are managed in separate files or using Terraform’s variable overrides
  • leverage Terraform’s ability to use module inheritance
  • define shared modules in the root directory and use them across environments with environment-specific variable values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Discuss your approach to organizing and storing Terraform state files?

A
  • use remote backends like Amazon S3 or HashiCorp Consul to store state files
  • for isolation, create separate S3 buckets or Consul namespaces for each environment
  • for collaborative settings, I emphasize the use of state locking mechanisms
How well did you know this?
1
Not at all
2
3
4
5
Perfectly