Terraform Assignment– 6
Terraform with DevOps & Cloud
Basic Questions
- Install Terraform on your CI runner and print the version in the pipeline logs.
- Create a Jenkins pipeline stage that runs terraform fmt -check and terraform validate.
- Create a GitLab CI job that runs terraform init and terraform plan on a sample workspace.
- Create a GitHub Actions workflow using hashicorp/setup-terraform to run init → plan.
- Store cloud credentials securely in your CI platform and reference them in the Terraform job.
- Cache the .terraform directory in CI to speed up future runs.
- Publish the terraform plan output as a pipeline artifact for review.
- Add a CI job that fails when terraform fmt -check detects formatting issues.
- Install Checkov locally and scan your Terraform folder with checkov -d ..
- Add a CI job that runs Checkov and fails on high-severity findings.
- Initialize a Terraform Cloud workspace and connect it to a VCS repository.
- Create a basic Sentinel policy that denies resources without a project tag.
- Enable policy checks in Terraform Cloud for your workspace.
- Configure providers for AWS and Azure in one root module without creating resources.
- Configure the Kubernetes provider pointing to a kubeconfig file path variable.
- Create a minimal Terraform file that defines an EKS cluster name variable only.
- Add an output that prints the active workspace terraform.workspace.
- Create a Makefile target ci-plan that wraps init → validate → plan.
- Add .terraform.lock.hcl to version control and explain its purpose in a README.
- Generate a skeleton main.tf/variables.tf/outputs.tf for an EKS stack without resources.
Intermediate Questions
- Create a Jenkins pipeline with separate stages: fmt, validate, plan, and archive plan.
- Create a GitLab .gitlab-ci.yml that runs plan on merge requests and apply on protected branches only.
- Create a GitHub Actions workflow that uses OpenID Connect (OIDC) to assume an AWS IAM role for plans.
- Add a manual approval step in CI before running terraform apply.
- Configure a remote S3 backend with DynamoDB locking and use it from CI.
- Run Checkov in CI and allow only documented suppressions via a checkov.yaml config file.
- Add a Terratest Go module that runs terraform init/plan and asserts no errors.
- Extend the Terratest to apply a small module and verify an output value.
- Write a Sentinel policy that restricts AWS regions to [“us-east-1″,”us-west-2”].
- Attach the Sentinel policy to your Terraform Cloud workspace and verify a deny event.
- Create a small multi-cloud plan: one AWS S3 bucket and one GCP storage bucket (separate providers).
- Use for_each to create three Kubernetes namespaces via the Kubernetes provider.
- Create a Helm release for NGINX Ingress using the Helm provider after the cluster is ready.
- Build an EKS cluster using the terraform-aws-eks Registry module with a single managed node group.
- Export kubeconfig data as outputs and write it to a file using a local_file resource.
- Add CI artifacts for kubeconfig and EKS outputs, restricted to protected branches.
- Implement drift detection in CI by running a nightly terraform plan and posting results.
- Add tagging standards in variables and apply them to all AWS resources in the stack.
- Create separate workspaces dev and prod and deploy the EKS stack with different node counts.
- Add a destroy job in CI that only runs on a destroy/* branch with manual approval.
Advanced Questions
- Build a full GitHub Actions workflow: OIDC assume-role → fmt → validate → plan → approval → apply for the EKS stack.
- Write a comprehensive Terratest that provisions EKS, fetches kubeconfig, and asserts node readiness (Ready status > 0).
- Extend Terratest to deploy a sample Service and verify it responds over ClusterIP using Kubernetes client-go.
- Enforce Sentinel policies: require mandatory tags, block public S3 buckets, and cap instance types to t3.*.
- Configure multi-cloud modules that deploy AWS EKS and Azure AKS from the same repo using per-workspace variables.
- Add Checkov as a required status check in your VCS and block merges on critical findings.
- Parameterize node groups with for_each, taints, labels, and desired/min/max scaling in the EKS module call.
- Automate VPC creation, EKS cluster, managed node groups, IAM roles for service accounts (IRSA), and outputs in a single apply.
- Deploy cluster add-ons with Terraform: VPC CNI, CoreDNS, kube-proxy, and metrics-server via Helm provider.
- Deliver an end-to-end hands-on: from CI trigger → plan on PR → Sentinel & Checkov gates → approval → apply EKS → Helm deploy NGINX → print Service endpoint in outputs.