instruction stringclasses 15
values | input stringlengths 43 1.91k | output stringlengths 77 27.9k | repo stringlengths 9 119 | license stringclasses 12
values | file_path stringlengths 5 187 | provider_family stringclasses 15
values | resource_types listlengths 1 37 | signature stringlengths 32 32 |
|---|---|---|---|---|---|---|---|---|
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSH key pair named `id_rsa` using the public key from the file path specified in the `key_path` variable, and launch a single t2.micro EC2 instance named `nginx-webserver` in the public subnet, using the AMI from the `ami` variable, associating it with the SSH key and a security group named `sgweb`, enabling ... | # Define SSH key pair for our instances
resource "aws_key_pair" "nginx_key" {
key_name = "id_rsa"
public_key = "${file("${var.key_path}")}"
}
# Define webserver inside the public subnet
resource "aws_instance" "nginx_wb" {
ami = "${var.ami}"
instance_type = "t2.micro"
key_name = "${aws_key_pair.nginx_key... | dsenarathna/Automation | MIT | nginx-server/resources.tf | aws | [
"aws_instance",
"aws_key_pair"
] | fa126a4074d33f0ba31aa42fe467e838 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with a randomly generated name, configure it to serve a static website using `index.html` as the index document and `error.html` as the custom error page, upload `index.html` and all `.jpg`, `.png`, and `.gif` files from the `assets` subdirectory into the bucket, and grant CloudFront read access to ... | resource "aws_s3_bucket" "website_bucket" {
# Bucket Naming Rules
#https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html?icmpid=docs_amazons3_console
# we want to assign a random bucket name
#bucket = var.bucket_name
tags = {
UserUuid = var.user_uuid
}
}
# https://registry.terraf... | bmacharia/terraform-beginner-bootcamp-2023 | MIT | modules/terrahome_aws/resource-storage.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_policy",
"aws_s3_bucket_website_configuration",
"aws_s3_object",
"terraform_data"
] | da766631b7dea4040265c954d43ca4b2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Application Load Balancer named with the pattern `<project-name>-alb-<environment>`, attach it to the provided subnet IDs, associate it with the designated security group, and tag it with the same name, the environment, and a Terraform marker set to true. | resource "aws_lb" "main" {
# Name of the load balancer
name = "${var.name}-alb-${var.environment}"
load_balancer_type = "application"
# Referencing the default subnets
subnets = var.subnets
# Referencing the security group
security_groups = [aws_security_group.alb.id]
t... | NicolaCostantino/Terragen | MIT | iaac/modules/terraform-aws-elb/load_balancers.tf | aws | [
"aws_lb"
] | 1d4da5ec9c0d49c7023f96a6ee9a240f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with a name derived from a configurable prefix, the current AWS account ID, and region, ensuring the name is between 3 and 63 characters; enable server-side encryption using either a specified KMS key or AES256, optionally enable versioning, and configure access logging to a designated bucket with p... | data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
locals {
current_region = data.aws_region.current.name
current_account = data.aws_caller_identity.current.account_id
bucket_name = var.use_default_naming_format ? format("%s-%s-%s", var.bucket_prefix, local.current_account, local.current... | HealthcareBlocks/hcblocks-terraform-modules-aws | Apache-2.0 | s3_bucket/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_cors_configuration",
"aws_s3_bucket_logging",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning"
] | 33d3abf86e464d82c046e70e6cd860c6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Cognito user pool named using the `user_pool_name` variable, a user pool client named using the `pool_client_name` variable associated with that pool, and a Cognito domain using the `dns_domain_name` variable linked to the same user pool. |
resource "aws_cognito_user_pool" "user_pool" {
name = var.user_pool_name
}
resource "aws_cognito_user_pool_client" "user_pool_client" {
name = var.pool_client_name
user_pool_id = aws_cognito_user_pool.user_pool.id
}
resource "aws_cognito... | khultman/Superalgos-IaC | Apache-2.0 | tf/modules/platform/aws/Identity/Cognito/main.tf | aws | [
"aws_cognito_user_pool",
"aws_cognito_user_pool_client",
"aws_cognito_user_pool_domain"
] | c345bebb17a78120b619d23976d951d1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named using the staging bucket variable, enable versioning, block all public access, configure a bucket policy that grants CloudFront read-only access only when the request originates from a specific CloudFront distribution, enable AES-256 server-side encryption, set lifecycle rules to delete noncur... | # S3 bucket for staging website content
resource "aws_s3_bucket" "website_staging" {
bucket = var.staging_bucket_name
tags = merge(
var.tags,
{
Name = "PythonCDMX Website Staging"
Environment = "staging"
}
)
}
# Enable versioning for staging bucket
resource "aws_s3_bucket_versioni... | PythonMexico/pythonCDMX | MIT | terraform/s3-staging.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_cors_configuration",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning"
] | 668ed151b0e9e1d0694588b1a517074b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create non-EKS subnets for each non-EKS subnet defined in `var.vpcConfig.subnets`, assigning each a public IP on launch, placing it in the specified availability zone, and tagging it with a name combining environment, location, common name, and subnet name. Separately, create EKS subnets for each subnet in `var.vpcConf... | resource "aws_subnet" "subnet" {
for_each = {
for subnet in var.vpcConfig.subnets :
subnet.name => subnet
if subnet.eksName == ""
}
vpc_id = aws_vpc.vpc.id
cidr_block = each.value.cidr_block
availability_zone = data.aws_availability_zones.available.names[each.va... | reddyavinash5/cloud-automation | MIT | aws/terraform/eks/tf-core-infra/subnet.tf | aws | [
"aws_subnet"
] | b76bfe0cd62406f1a27467ee87fb9a1e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Backup solution with two backup plans: one that replicates backups to a secondary region using a vault protected by a replica KMS key, and another that backs up only locally; configure an IAM role with the required AWS Backup service roles and permissions, and define backup selections based on configurabl... | provider "aws" {
alias = "dr"
region = var.dr_region
}
data "aws_caller_identity" "current" {}
locals {
account_id = data.aws_caller_identity.current.account_id
backup_plan_ids = [
aws_backup_plan.this.id,
aws_backup_plan.and_replicate.id
]
}
data "aws_iam_policy_document" "assume" {
statement ... | rhythmictech/terraform-aws-backup | MIT | main.tf | aws | [
"aws_backup_plan",
"aws_backup_selection",
"aws_backup_vault",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 8d4771c4caddddd7501ba38b97c1959d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create multiple security groups named using the environment and a key from the security_group variable, all associated with the specified VPC ID, and attach a set of inbound and outbound rules defined in local.rules—each rule specifying port ranges, protocol, CIDR blocks (IPv4 and IPv6), or source security group IDs—wh... | resource "aws_security_group" "sg" {
for_each = var.security_group
name = "${var.environment}-${each.key}-security-group"
tags = {
Name="${var.environment}-${each.key}-security-group"
}
vpc_id = var.vpc_id
}
resource "aws_security_group_rule" "rules" {
count = length(local.rules)
security_gr... | guruprasathselvaraj/terraform-3-tire-arch | MIT | modules/security_group/main.tf | aws | [
"aws_security_group",
"aws_security_group_rule"
] | 28b7e76f01d83b3d4e41f6c861b4f6aa |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a standard network ACL in the us-east-1 region that allows all inbound and outbound traffic from any IP address, and associate it with the nine specific subnets: compute_a, compute_b, compute_c, compute_native_a, compute_native_b, compute_native_c, service_endpoint_a, service_endpoint_b, and service_endpoint_c. | resource "aws_network_acl" "standard" {
provider = aws.use2
vpc_id = aws_vpc.main.id
egress {
rule_no = 100
protocol = "-1"
action = "allow"
cidr_block = "0.0.0.0/0"
from_port = 0
to_port = 0
}
ingress {
rule_no = 100
protocol = "-1"
action = "allo... | MyHealthCo/enterprise-services | BSD-3-Clause | k8s/ipv6/use2/network_acls.tf | aws | [
"aws_network_acl",
"aws_network_acl_association"
] | 6933674e2c336e9fca00e4c4b89eaae5 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an application load balancer named “whiz-alb” in the default VPC across us-east-1a and us-east-1b subnets, with an HTTP listener on port 80 forwarding traffic to a target group named “whiz-tg” that health-checks instances every 10 seconds at the root path. Launch two t2.micro EC2 instances using AMI ami-01cc34ab... | provider "aws" {
region = "${var.region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
}
############ Creating Security Group for EC2 & ELB ############
resource "aws_security_group" "web-server" {
name = "web-server"
description = "Allow incoming HTTP Connections... | hibachouchou/Create-an-Application-Load-Balancer---incoming-traffic--EC2-Instances--Terraform | MIT | main.tf | aws | [
"aws_instance",
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group",
"aws_lb_target_group_attachment",
"aws_security_group"
] | 7c6d38b970d4865c5eba16923193f808 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with a configurable CIDR block, DNS support, and DNS hostnames enabled, along with public, private, database, and control plane subnets distributed across availability zones, including an internet gateway and a single NAT gateway in the first public subnet to enable outbound internet access for private res... | # Copyright © 2021-2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# This is customized based on - https://github.com/terraform-aws-modules/terraform-aws-vpc
locals {
vpc_id = var.vpc_id == null ? aws_vpc.vpc[0].id : data.aws_vpc.vpc[0].id
existing_sub... | navarro-chamberlain/viya4 | Apache-2.0 | modules/aws_vpc/main.tf | aws | [
"aws_db_subnet_group",
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc",
"aws_vpc_endpoint"
] | a0e93625173abdb7d48e0cbca939fa07 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Application Load Balancer listener rule that routes traffic based on optional host header and path pattern conditions, supporting forward, redirect, fixed-response, Cognito authentication, OIDC authentication, and weighted forward actions with optional stickiness, using the provided listener ARN and priority. | resource "aws_lb_listener_rule" "this" {
listener_arn = var.listener_arn
priority = var.priority
dynamic "condition" {
for_each = length(var.alb_hosts) > 0 ? [1] : []
content {
host_header {
values = var.alb_hosts
}
}
}
dynamic "condition" {
for_each = length(var.alb_... | chiwooiac/tfmodule-aws-alb | MIT | modules/rule/main.tf | aws | [
"aws_lb_listener_rule"
] | 68bcadc32f876ddd716a0e8582abfa8d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Lambda function named AWSAlertValidationErrorAlarm using Python 3.12, packaged from ErrorAlarm.py, with a 30-second timeout and tagged for monitoring; provision an IAM role allowing it to assume the Lambda execution role and write logs to CloudWatch with a 30-day retention period for the function’s log group. | data "archive_file" "error_alarm_zip" {
type = "zip"
source_file = "${path.module}/ErrorAlarm.py"
output_path = "${path.module}/ErrorAlarm.zip"
}
resource "aws_lambda_function" "error_alarm" {
filename = data.archive_file.error_alarm_zip.output_path
function_name = "AWSAlertValidationErrorAlarm"
... | JBVK/AWSAlertValidation | MIT | Lambda/ErrorAlarm/main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_iam_role",
"aws_iam_role_policy",
"aws_lambda_function"
] | 348a1bc97893067394ea3a24ea55e083 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Deploy the Argo CD Helm chart into a new `argocd` namespace, configure its server to expose a LoadBalancer service with an insecure HTTP endpoint, enable an ALB ingress with internet-facing scheme, IP target type, and root-path health checks, set the admin password to the bcrypt hash of `AdminPassword123!`, enable Appl... | resource "helm_release" "argocd" {
name = "argocd"
repository = "https://argoproj.github.io/argo-helm"
chart = "argo-cd"
namespace = "argocd"
create_namespace = true
set = [
{
name = "server.service.type"
value = "LoadBalancer"
},
{
name =... | ewsffg/terraform-eks | MIT | modules/argocd/helm.tf | k8s | [
"helm_release",
"kubernetes_namespace"
] | 5b4a3e845209a120d8a0e98fa8c07e2f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with the name provided via `bucket_name`, configure it to host a static website using `index.html` as the index and `error.html` as the error page, enable public read access to all objects in the bucket by setting the ACL to `public-read`, disable all public access blocking controls, and ensure the ... | resource "aws_s3_bucket" "s3_bucket" {
bucket = var.bucket_name
tags = var.bucket_tags
force_destroy = true #allows to destroy bucket even if it is not empty
}
data "aws_iam_policy_document" "s3_read_permissions-website" {
statement {
effect = "Allow"
principals {
type = "*"
identi... | hemant-technerd/terraform-aws-s3-website | Apache-2.0 | main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_acl",
"aws_s3_bucket_ownership_controls",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_website_configuration"
] | f5faf920a6ecc59c287495a0fbd72d32 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a private S3 bucket with the name specified by the `bucket_name` variable, enforce that all access requires secure transport (HTTPS), block all public access at the bucket and account level, enable server-side encryption using the AWS managed KMS key for S3, and configure versioning according to the `bucket_vers... | data "aws_iam_policy_document" "this" {
source_policy_documents = [var.policy]
statement {
sid = "DenyInsecureTransport"
actions = ["s3:*"]
effect = "Deny"
principals {
type = "*"
identifiers = ["*"]
}
resources = ["arn:aws:s3:::${var.bucket_name}/*"]
condition {... | woffenden/infrastructure | MIT | terraform/modules/aws/s3/modules/private-bucket/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_acl",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning"
] | 19cf6bb2f427ea9e24e74dd6b7b16633 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an API Gateway v2 custom domain name using the domain specified in `var.apigatewayv2_domain_name_domain_name`, configure its TLS certificate and endpoint type via `var.apigatewayv2_domain_name_domain_name_configuration`, optionally enable mutual TLS authentication using a truststore from `var.apigatewayv2_domain... | #---------------------------------------------------
# AWS API Gateway v2 domain name
#---------------------------------------------------
resource "aws_apigatewayv2_domain_name" "apigatewayv2_domain_name" {
count = var.enable_apigatewayv2_domain_name ? 1 : 0
domain_name = var.apigatewayv2_domain_name_domain_name
... | SebastianUA/terraform | Apache-2.0 | aws/modules/apigatewayv2/apigatewayv2_domain_name.tf | aws | [
"aws_apigatewayv2_domain_name"
] | 966a0edcdc64e3c4b1dd76c7ddc5e91d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EC2 instance of type t2.micro using AMI ami-0e37e42dff65024ae, attach it to the public subnet from the remote VPC state, assign it a public IP, enable detailed CloudWatch monitoring, associate it with the ECS instance profile from remote IAM state, provision 30 GiB of gp2 storage as its root volume, and confi... | resource "aws_security_group" "instance" {
name = "instance"
description = "instance sg"
vpc_id = data.terraform_remote_state.vpc.outputs.vpc_id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "instance" {
ami ... | sunakan/erapp | MIT | terraform/service/main.tf | aws | [
"aws_instance",
"aws_security_group"
] | 6361bbfbc73439a758d6fcff6527587c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS VPC endpoint for the API Gateway service in the current region, configured as an interface endpoint, with private DNS resolution enabled, and only when the deployment flag is set to true. | data "aws_region" "current" {}
resource "aws_vpc_endpoint" "private_api_gateway" {
count = var.api_gateway_vpc_endpoint_deployment ? 1 : 0
service_name = "cn.com.amazonaws.${data.aws_region.current.name}.execute-api"
vpc_endpoint_type = "Interface"
vpc_id = var.vpc_id
subnet_ids ... | camillehe1992/terraform-cicd-pipeline-github-actions | Apache-2.0 | terraform/modules/vpc_endpoint/endpoints.tf | aws | [
"aws_vpc_endpoint"
] | 75684feae37aac97e78bab07b661e70b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Cognito user pool named using the `pool_name` variable, and configure a client named "API_Example_Key" attached to it that permits password-based authentication, SRP-based authentication, and refresh token usage. | resource "aws_cognito_user_pool" "api_pool" {
name = var.pool_name
}
resource "aws_cognito_user_pool_client" "api_client" {
name = "API_Example_Key"
user_pool_id = aws_cognito_user_pool.api_pool.id
explicit_auth_flows = [
"ALLOW_USER_PASSWORD_AUTH",
"ALLOW_USER_SRP_AUTH",
"ALLOW_REFRESH_TOK... | srinivas-pradhan/api_implementation | MIT | modules/api_example/cognito.tf | aws | [
"aws_cognito_user_pool",
"aws_cognito_user_pool_client"
] | caf114911f64eb32be8f7c9307fc5061 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create three sets of subnets in the specified VPC: public subnets with one per availability zone, each assigned a CIDR block from `var.public_subnet_cidrs`, configured to automatically assign public IP addresses on launch, and named with the app name, “public”, and the availability zone; private subnets, also one per a... | locals {
public_subnets = [
for i, cidr in var.public_subnet_cidrs : {
cidr_block = cidr
availability_zone = element(var.availability_zones, i % length(var.availability_zones))
}
]
private_subnets = [
for i, cidr in var.private_subnet_cidrs : {
cidr_block = cidr
... | wwwtskt/tfmodule | MIT | aws/network/subnet/main.tf | aws | [
"aws_subnet"
] | 1fe285ac80759efbd9524d3af7b0ec6c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a configurable number of EC2 instances across available availability zones, each using a specified AMI, instance type, and user data script, with optional key pair, detailed monitoring, and security groups; attach a root EBS volume and additional EBS volumes with customizable size, type, encryption, and IOPS,... | data "aws_availability_zones" "this" {
state = "available"
}
resource "aws_instance" "this" {
count = var.instance_count
ami = var.ami
instance_type = var.instance_type
user_data = var.user_data
key_name = var.key_name
monitoring = var.m... | dikaeinstein/cloud-devops-engineer | MIT | ec2/main.tf | aws | [
"aws_instance"
] | 16b9ab4509cf56d3546346492adf699e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named “bedrock-bastion-instance” that EC2 instances can assume, attach the AWS managed policies for SSM and CloudWatch Agent to that role. | data "aws_iam_policy_document" "ec2_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
identifiers = ["ec2.amazonaws.com"]
type = "Service"
}
}
}
resource "aws_iam_role" "bastion_instance" {
name = "bedrock-bastion-instance"
assume_role_pol... | figurate/bedrock | MIT | roles/bastion/aws/instance_profile.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 4d7061c82ce718d217c121bdad1e8cce |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Request an ACM certificate in the US East (N. Virginia) region for the root domain and all domains listed in the subject alternative names variable, using DNS validation; create a Route 53 validation record for each domain validation option with a TTL of 60 seconds, placing them in the hosted zone specified by the host... | resource "aws_acm_certificate" "cert" {
provider = aws.virginia
domain_name = var.root_domain_name
subject_alternative_names = var.subject_alternative_names
validation_method = "DNS"
}
resource "aws_route53_record" "cert_validations" {
count = length(var.subject_alternative_names)
zone_id = local.zone_not... | senter7/Terraform-Online-Static-Website | Apache-2.0 | modules/website/certificate.tf | aws | [
"aws_acm_certificate",
"aws_acm_certificate_validation",
"aws_route53_record"
] | 0d0cf232a8a3ecd67b9d8920fca3b611 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an OIDC identity provider in AWS for GitHub Actions using a specified URL and TLS certificate thumbprints, then create an IAM role named via a variable that allows GitHub Actions to assume it via web identity, with conditions restricting access to specific repositories and the AWS STS audience, attach a list of ... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
tls = {
source = "hashicorp/tls"
}
}
}
# Data source to fetch AWS caller identity
data "aws_caller_identity" "current" {}
# Data source to fetch AWS partition (e.g., aws, aws-cn)
data "aws_partition" "current" {}
d... | srajasimman/terraform-aws-github-oidc-iam | MIT | main.tf | aws | [
"aws_iam_openid_connect_provider",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 6ef8c6a098320468293d3579952745ad |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a default VPC with CIDR 10.0.0.0/16 for a Limble assessment, including two public subnets (10.0.0.0/20 and 10.0.16.0/20) connected to an internet gateway and a public route table, and two private subnets (10.0.128.0/20 and 10.0.144.0/20) with NAT gateway access via a single Elastic IP in the first public subnet ... | data "aws_availability_zones" "available" {}
# default vpc for Limble assessment
resource "aws_vpc" "default" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "${var.name}-vpc"
assessment = var.name
}
}
# public subnet 1
resource "aws_subnet" "public_subnet_1" {
vpc_id = aws_vpc.default.id
ci... | Mhart12/limble-assessment | MIT | aws_resources/vpc/main.tf | aws | [
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 844faf7e4e00681f942f5a8ec50cb428 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS cluster with a configurable name, enable or disable CloudWatch Container Insights based on a variable, and optionally configure capacity providers—including a default capacity provider strategy with weighted targets and base counts—if any are provided. | # -----------------------------------------------------------------------------
# ECS Cluster Module
# Creates a shared ECS cluster that can host multiple services
# -----------------------------------------------------------------------------
terraform {
required_providers {
aws = {
source = "hashicorp/... | llamandcoco/infra-modules | MIT | terraform/ecs-cluster/main.tf | aws | [
"aws_ecs_cluster",
"aws_ecs_cluster_capacity_providers"
] | a7a10b517b99f3a90a7dd748875ae7a5 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision one t2.micro EC2 instance in the California region using AMI ami-03130878b60947df3, and provision one t2.micro EC2 instance in the Oregon region using AMI ami-0a36eb8fadc976275. | /* Staus of this template : Run perfect */
resource "aws_instance" "testVM_California" {
provider = aws.California
ami = "ami-03130878b60947df3"
instance_type = "t2.micro"
count = 1
}
resource "aws_instance" "testVM_Oregon" {
provider = aws.Oregon
ami = "ami-0a36eb8fadc976275"
instance_... | arnathan2k/terraform-samples | Apache-2.0 | 01-01-create-vms/main.tf | aws | [
"aws_instance"
] | e386c4a805b8ba1f90b5049d333a3fbc |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an OpenSearch domain with the specified name and engine version, enabled with internal user database and master credentials from a secret, node-to-node and at-rest encryption, HTTPS-only endpoints using TLS 1.0 or higher, a cluster with the given instance count and type, zone awareness enabled when more than ... | resource "aws_opensearch_domain" "opensearch" {
count = var.opensearch.enable ? 1 : 0
domain_name = var.opensearch.domain_name
engine_version = var.opensearch.engine_version
advanced_security_options {
enabled = true
internal_user_database_enabled = true
master_use... | dspace-group/dspace-reference-architecture-aws | MIT | modules/ivs_aws_instance/opensearch.tf | k8s | [
"aws_opensearch_domain"
] | 13e7ed6d9bbfd0a16e76d89232a330fc |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `s3-logs-` followed by a random six-character lowercase alphanumeric suffix to serve as a centralized logging destination. For each pipeline in `local.safe_codepipeline_pipelines`, create a uniquely suffixed S3 bucket named `pipeline-artifacts-<pipeline-name>-<four-character-random-suffix>` wi... | # Instructions: Create resources for S3
resource "random_string" "suffix" {
length = 6
upper = false
special = false
}
resource "aws_s3_bucket" "logging_bucket" {
bucket = "s3-logs-${random_string.suffix.result}"
}
resource "random_string" "codepipeline_artifacts_s3_buckets" {
for_each = local.safe_code... | joeycloudio/module-aws-tf-cicd | MIT | s3.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_logging",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning",
"random_string"
] | 4fb106d4deb49f5325030e8b2dc89f42 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create one or more load balancer target groups based on a variable list, each configured with a VPC ID, backend port and protocol (converted to uppercase), optional target type, deregistration delay, slow start duration, proxy protocol v2, and lambda multi-value headers; each target group should support custom health c... |
resource "aws_lb_target_group" "main" {
count = var.create_tg ? length(var.target_groups) : 0
name = lookup(var.target_groups[count.index], "name", null)
name_prefix = lookup(var.target_groups[count.index], "name_prefix", null)
vpc_id = var.vpc_id
port = lookup(var.target_groups[count.in... | miraiadvisory/terraform-aws-alb-tg | Apache-2.0 | main.tf | aws | [
"aws_lb_target_group",
"aws_lb_target_group_attachment"
] | f169f5b1eba2b0a1d8c6a05975c609a2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Route 53 A record for the fully qualified domain name formed by appending a dot to the value of `dns_name_tfe`, pointing to the public IP address stored in `tfe_instance_public_ip`, with a TTL of 300 seconds, in the Route 53 hosted zone whose name is provided via `dns_zone_name`. |
data "aws_route53_zone" "zone" {
name = var.dns_zone_name
}
resource "aws_route53_record" "www" {
zone_id = data.aws_route53_zone.zone.zone_id
name = "${var.dns_name_tfe}."
type = "A"
ttl = "300"
records = [var.tfe_instance_public_ip]
} | berchev/ptfe-airgap-automated | MIT | modules/r53/dns_record.tf | aws | [
"aws_route53_record"
] | 778c27139e6d6e90347f9bf45843651c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named “DataIngressServer” that ECS tasks can assume, attach a policy granting it permissions to pull container images from a specific ECR repository, decrypt data using a designated KMS key, read configuration objects from a specific S3 bucket and list the bucket, export and retrieve a specific ACM c... | data "aws_iam_policy_document" "sft_agent_task" {
statement {
sid = "PullIngressSFTAgentImageECRrepository"
actions = [
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
]
resources = ["arn:aws:ecr:${var.region}:${var.account[var.management_accoun... | dwp/dataworks-aws-data-ingress | ISC | terraform/data-ingress-sft-task/sft_agent_iam.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | da80417135874432192ee297158a84de |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create four CodeCommit repositories named avbank_web, avbank_transactions, avbank_accounts, and avbank_discounts with descriptions indicating they serve as the web tier app and the transactions, accounts, and discounts services respectively for the AvailableBank project. | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
resource "aws_codecommit_repository" "avbank_web_repo" {
repository_name = "avbank_web"
description = "Web tier app for the AvailableBank project"
}
resource "aws_codecommit_repository" "avbank_transactions_repo" {
re... | tomasz-grzesiak/HighAvailabilityOnAWS | MIT | modules/repositories/main.tf | aws | [
"aws_codecommit_repository"
] | a5d28d537195e0f478451492688bf4dd |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Store the ARN of the load balancer and the ARN of its main listener as SSM parameters under the path `/project-name/ecs/alb_arn` and `/project-name/ecs/alb_listener` respectively, using the String parameter type. | resource "aws_ssm_parameter" "lb_arn" {
name = format("/%s/ecs/alb_arn", var.project_name)
type = "String"
value = aws_lb.main.arn
}
resource "aws_ssm_parameter" "lb_listener" {
name = format("/%s/ecs/alb_listener", var.project_name)
type = "String"
value = aws_lb_listener.main.arn
} | pmmenezes/terraform-ecs-cluster | MIT | parameters_store.tf | aws | [
"aws_ssm_parameter"
] | 4531cb7835121d9e90181a97e1d0e9d4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an internet-facing Application Load Balancer named according to the `name` variable, deployed across the subnets specified in the `subnets` variable, and secured with a security group named `<name>-dmz` that permits inbound HTTPS (port 443) and HTTP (port 80) traffic from anywhere (0.0.0.0/0) and allows all outb... | resource "aws_lb" "alb" {
name = var.name
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.webdmz.id]
subnets = var.subnets
tags = {
Provisioner = "terraform"
Environment = var.environment
}
}
resource "aws_security_g... | ljossha/terraform-simple-app | Apache-2.0 | modules/alb/main.tf | aws | [
"aws_lb",
"aws_security_group"
] | 0afd1e265c6a90ff5ae3c5a8fdd6d342 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two ECR repositories named after the project—`<project_name>-api` and `<project_name>-nginx`—both configured to allow mutable image tags and automatically scan images on push; for each repository, enforce a lifecycle policy that retains only the 10 most recent images and expires older ones. | resource "aws_ecr_repository" "api" {
name = "${var.project_name}-api"
image_tag_mutability = "MUTABLE"
image_scanning_configuration {
scan_on_push = true
}
}
resource "aws_ecr_lifecycle_policy" "api" {
repository = aws_ecr_repository.api.name
policy = jsonencode({
rules = [
... | heschmat/ultimate-terraform-aws | BSD-3-Clause | setup/ecr.tf | aws | [
"aws_ecr_lifecycle_policy",
"aws_ecr_repository"
] | c6a8b762b738db54e27f54461b7cbe17 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a placement group with the name and strategy specified by variables, and an Auto Scaling group named after the variable `name`, using the given minimum, maximum, and desired capacity values, with a 300-second cooldown and health check grace period, health checks based on EC2 status, instances launched into the p... | resource "aws_placement_group" "main" {
name = var.name
strategy = var.placement_group
tags = var.tags
}
resource "aws_autoscaling_group" "main" {
name = var.name
default_cooldown = 300
desired_capacity = var.scaling_config.min_size
force_delete ... | ben-x/cloudpedia | MIT-0 | content/common-modules/aws-ec2-fleet/asg.tf | aws | [
"aws_autoscaling_group",
"aws_placement_group"
] | 0ea5b733b0e22aa91155253d5b4e39ae |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an SSL/TLS certificate for a subdomain of jordibru.cloud, using DNS validation, and ensure it’s issued in the us-east-1 region; automatically create the necessary DNS validation records in the jordibru.cloud hosted zone with a 60-second TTL and overwrite any existing records with the same name and type. | data "aws_route53_zone" "jordibru_cloud" {
name = "jordibru.cloud"
}
resource "aws_acm_certificate" "domain_certificate" {
domain_name = "${var.subdomain}.jordibru.cloud"
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
provider = aws.us-east-1-acm
tags = {
terraform ... | JordiiBru/aws-acm | MIT | main.tf | aws | [
"aws_acm_certificate",
"aws_acm_certificate_validation",
"aws_route53_record"
] | 21fdca111960ac1257eb5469de9af0c8 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CodeBuild project named after the Lambda function with deployment suffix, configured to pull source from CodePipeline, use a specified IAM role or a newly created one, enable CloudWatch Logs with a retention period defined by a variable, disable S3 logs, set the build environment with Python 3.9 runtime and cu... | resource "aws_cloudwatch_log_group" "this" {
name = "/aws/codebuild/${var.function_name}-deployment"
retention_in_days = var.codebuild_cloudwatch_logs_retention_in_days
tags = var.tags
}
resource "aws_codebuild_project" "this" {
name = "${var.function_name}-deployment"
servi... | willsc/terraform-lambda | MIT | modules/deployment/codebuild.tf | aws | [
"aws_cloudwatch_log_group",
"aws_codebuild_project"
] | cbea4b60e412efac9a404f8880fd4e2f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create one EC2 instance per VPC defined in the `vpcs` variable, each using AMI `ami-0599b6e53ca798bb2`, placed in the corresponding subnet, sized as `t2.micro`, assigned a static private IP from the VPC’s configuration, tagged with a name combining the project name and its index, and attached to an IAM instance profile... | resource "aws_instance" "instances" {
count = length(var.vpcs)
ami = "ami-0599b6e53ca798bb2"
subnet_id = aws_subnet.subnets[count.index].id
instance_type = "t2.micro"
iam_instance_profile = aws_iam_instance_profile.ssm_managed.name
private_ip = var... | Hasuzawa/aws-projects | MIT | aws/09-vpc-peering-transit-gateway/instance.tf | aws | [
"aws_instance"
] | f60100cd23197f993172c91765d37d31 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a single EC2 instance named `<prefix>-app-server` with role Web-Server, using the specified AMI ID, instance type, subnet, key pair, and security group, and apply common tags to it. | # modules/aws_vm/main.tf
# Creates a single AWS EC2 instance.
resource "aws_instance" "app_server" {
ami = var.ami_id
instance_type = var.instance_type
subnet_id = var.subnet_id
key_name = var.key_name
vpc_security_group_ids = [var.security_group_id]
... | Abdulrahman-A-Muhammad/terraform-multicloud | MIT | modules/aws_vm/main.tf | aws | [
"aws_instance"
] | 877488a709f76981c8065b0f1a605d7a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create three VPCs named prod, nonprod, and shared in the us-east-2 region, with CIDR blocks 10.254.0.0/16, 10.253.0.0/16, and 10.255.0.0/16 respectively, each enabling DNS hostnames and tagged with their names. Provision private subnets in prod and nonprod across all available Availability Zones, and public subnets in ... | provider "aws" {
region = "us-east-2"
}
data "aws_region" "current" {}
resource "aws_vpc" "prod" {
cidr_block = "10.254.0.0/16"
enable_dns_hostnames = true
tags = {
Name = "prod"
}
}
resource "aws_vpc" "nonprod" {
cidr_block = "10.253.0.0/16"
enable_dns_hostnames = true
tags... | mannbiher/aws-eks-lab | MIT | infrastructure/network/main.tf | aws | [
"aws_internet_gateway",
"aws_main_route_table_association",
"aws_route_table",
"aws_subnet",
"aws_vpc",
"aws_vpc_peering_connection",
"aws_vpc_peering_connection_options"
] | d133fd85732838afa14664bf9b99780b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with a single public subnet, an internet gateway attached to the VPC, and a route table that directs all traffic (0.0.0.0/0) to the internet gateway; associate the subnet with the route table. Configure a security group that allows inbound SSH (port 22), HTTPS (port 443), Consul (port 8500), Serf LAN (port... | # create the VPC
resource "aws_vpc" "vpc" {
cidr_block = var.vpcCIDRblock
instance_tenancy = var.instanceTenancy
enable_dns_support = var.dnsSupport
enable_dns_hostnames = var.dnsHostNames
tags = {
Name = "VPC_${var.vpc_name}"
}
} # end resource
# create the subnet
resource "aws_subnet... | chavo1/aws-vpc-terraform | MIT | vpc.tf | aws | [
"aws_internet_gateway",
"aws_network_acl",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | 68aaadc1916c84d497e8f35a2ec4a500 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group in the specified VPC with a name derived from a variable, allow SSH access on port 22 from a configurable set of CIDR blocks, permit HTTP on port 80 and HTTPS on port 443 from their respective configurable CIDR blocks, add one or more custom data port rules on port 8080 based on a list of CIDR b... | resource "aws_security_group" "main" {
name_prefix = var.security_group_name
vpc_id = var.vpc_id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = var.ssh_cidr_blocks
description = "SSH access"
}
ingress {
from_port = 80
to_port = 80
pro... | Asiwomex/Terraform-project-aws | MIT | modules/security_group/main.tf | aws | [
"aws_security_group"
] | 564b8461d0428164b83c38e04ed22e4e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Set up logging for a WAFv2 web ACL by sending its logs to a Kinesis Firehose delivery stream that delivers them to an S3 bucket, with the Firehose stream named using the web ACL’s name and configured to store logs under a CloudFront-specific prefix in the bucket. |
resource "aws_wafv2_web_acl_logging_configuration" "wafv2_logging_configuration" {
log_destination_configs = [aws_kinesis_firehose_delivery_stream.wafv2_logging_firehose_stream.arn]
resource_arn = var.web_acl_arn
}
resource "aws_kinesis_firehose_delivery_stream" "wafv2_logging_firehose_stream" {
name... | KayakinCoder/filmdrop-learn | Apache-2.0 | modules/cloudfront/waf_qp_bytematch/log_configuration/kinesis_log_configuration.tf | aws | [
"aws_kinesis_firehose_delivery_stream",
"aws_wafv2_web_acl_logging_configuration"
] | 7ab5cb391f76447282e656e96f752987 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a snapshot volume permission that grants a specific AWS account access to restore from a given snapshot in a designated region. | resource "aws_snapshot_create_volume_permission" "this" {
region = var.region
snapshot_id = var.snapshot_id
account_id = var.account_id
} | ebogdum/terraform-providers | MIT | aws/resources/snapshot_create_volume_permission/main.tf | aws | [
"aws_snapshot_create_volume_permission"
] | 9bb83609aef0a1575473829969d3642b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named with the resource prefix followed by `-ec2-github-runner` that allows EC2 instances to assume it, attach the AWS managed policy `AmazonSSMManagedInstanceCore` to it, and create a matching IAM instance profile with the same name and a tag `Name` set to `AWS EC2 Github runner instance profile`. | resource "aws_iam_role" "ec2_github_runner" {
name = "${var.resource_prefix}-ec2-github-runner"
managed_policy_arns = [
"arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore",
]
assume_role_policy = data.aws_iam_policy_document.ec2_assume_role.json
}
resource "aws_iam_instance_profile" "ec2_github_runner" ... | QuiNovas/terraform-aws-ec2-github-runner | Apache-2.0 | role.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_role"
] | 485fcb4ed8f9e4f8c047f853d8a316cb |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group named “allow_rdp” that permits inbound RDP traffic on TCP port 3389 from any IP address, and allow all outbound traffic to any destination. Tag the security group with the name “allow_rdp_sg”. | # define security group to allow rdp access
resource "aws_security_group" "allow_rdp" {
name = "allow_rdp"
ingress {
from_port = 3389
to_port = 3389
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ... | inderpal2406/terraform_assignment | MIT | sg.tf | aws | [
"aws_security_group"
] | 53e523943bda603c43826d453218fac9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Deploy a single-container ECS Fargate service named after the project and environment, running in two public subnets across Availability Zones with automatic public IP assignment, allowing port 5000 traffic via a designated security group, using standard ECS rolling deployments with 50% minimum and 200% maximum healthy... | # ------------------------------------------------------------------------------
# ECS Fargate Service
# This defines how the task will be deployed and run across subnets and AZs
# ------------------------------------------------------------------------------
resource "aws_ecs_service" "app" {
name = "${v... | lyn-boyu/aws-dev-ops | MIT | apps/flask-api-ecs-terraform/terraform/service.tf | aws | [
"aws_ecs_service"
] | d09b5eec4bb1b676c42effedc50028e4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a TCP load balancer target group named with the provided name and port, attach multiple targets from the given list to it on the specified port, and configure a TCP listener on the provided load balancer to forward traffic to that target group. | resource "aws_lb_target_group" "aws_lb_target_group" {
name = "${var.name}-target-group-${var.port}"
port = var.port
protocol = "TCP"
vpc_id = var.vpc_id
tags = var.tags
}
resource "aws_lb_target_group_attachment" "aws_lb_target_group_attachment" {
count = length(var.target_id)
#for_e... | kunalb19/terraform-aws-create-elb | Apache-2.0 | main.tf | aws | [
"aws_lb_listener",
"aws_lb_target_group",
"aws_lb_target_group_attachment"
] | 544c853a9d5cb44e5d773d9b500974ed |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Service Catalog tag option with a configurable key, value, and region, set to active or inactive as specified, and define custom timeouts for create, read, update, and delete operations using the provided variable values. | resource "aws_servicecatalog_tag_option" "this" {
key = var.key
value = var.value
region = var.region
active = var.active
timeouts {
create = var.timeouts.create
read = var.timeouts.read
update = var.timeouts.update
delete = var.timeouts.delete
}
} | ebogdum/terraform-providers | MIT | aws/resources/servicecatalog_tag_option/main.tf | aws | [
"aws_servicecatalog_tag_option"
] | 787fab2a097f5e117b6cdfaf27f52291 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named with the domain suffix “-redirect”, configured to redirect all requests to the HTTPS version of the domain, with private access and automatic deletion on destroy. Set up a CloudFront distribution with the domain alias pointing to that bucket, using an ACM certificate for TLS 1.2 or higher, HTT... | locals {
s3_redirect_origin_id = "s3-redirect-${var.base_name}"
}
########## S3 bucket ##########
resource "aws_s3_bucket" "redirect" {
bucket = "${var.domain}-redirect"
acl = "private"
force_destroy = true
website {
redirect_all_requests_to = "https://${var.domain}"
}
tags = {
... | bridgecrew-perf4/terraform-modules-65 | MIT | modules/staticsite/cfredirect.tf | aws | [
"aws_cloudfront_distribution",
"aws_s3_bucket"
] | fca20e7d15a5aef8c80dc9eb8e4669d9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a public route table in the specified VPC that routes all internet-bound traffic (0.0.0.0/0) through the internet gateway, and tag it with the project name as both the Name and Project tags. | resource "aws_route_table" "route-table-pub" {
vpc_id = aws_vpc.vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.internet-gateway.id
}
tags = merge(
var.tags,
{
Name = "${var.project_name}-route-table-pub"
Project = "${var.project_name}"
}
)
} | thdesous/aws-eks-cluster | MIT | infra/modules/network/route-table-public.tf | aws | [
"aws_route_table"
] | 2dc1aee087b770c962e142ae3e045075 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group named after the bastion instance variable, attached to the specified VPC, with a description that includes the bastion name and tags the group with the same name; allow all outbound traffic to any IPv4 and IPv6 destination. | resource "aws_security_group" "bastion_group" {
name = var.bastion_name
description = "${var.bastion_name} ec2 instance security group"
vpc_id = var.vpc_id
tags = {
Name = var.bastion_name
}
}
resource "aws_security_group_rule" "outbound" {
from_port = 0
protocol = "-1"
security_group_id = aws_sec... | jwa-lab/terraform-aws-vpc-bastion | Apache-2.0 | security.tf | aws | [
"aws_security_group",
"aws_security_group_rule"
] | 4cebadbed76bad2fb169e0c8836674e2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECR repository named after the short project name with immutable image tags, encrypted using the specified KMS key alias, with image scanning enabled on push, and set a lifecycle policy to automatically expire untagged images older than seven days. | data "aws_kms_key" "ecr_kms_key" {
key_id = "alias/${var.general_kms_key_alias}" # Replace with your KMS key alias
}
resource "aws_ecr_repository" "main" {
name = "${var.short_project_name}-repo"
image_tag_mutability = "IMMUTABLE"
encryption_configuration {
encryption_type = "KMS"
kms_... | ogbrown/ogb-ecr-tf-proj | MIT | modules/ecr/main.tf | aws | [
"aws_ecr_lifecycle_policy",
"aws_ecr_repository"
] | 2c617f29db3be50a19d16238a3056799 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudFront distribution for the main domain that serves static content from an S3 bucket using Origin Access Control, optionally routes API traffic to an API Gateway endpoint, supports custom origins with configurable headers and protocols, enforces HTTPS with TLS 1.2 minimum, uses ACM certificate validation f... | locals {
s3_origin_id = var.cf_website_origin_id != "" ? var.cf_website_origin_id : "S3Website-${local.resolved_bucket_name}"
lambda_origin_id = var.cf_lambda_origin_id != "" ? var.cf_lambda_origin_id : "Lambda-${local.resolved_lambda_function_name}"
resolved_cf_request_function_name = var.cf_request_functi... | facundodossantos/terraform-aws-hosting-lambda | MIT | resources_cf.tf | aws | [
"aws_cloudfront_distribution",
"aws_cloudfront_function",
"aws_cloudfront_origin_access_control"
] | 87c33aed012f6764ae0412c61be9000b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an internet-facing Application Load Balancer named `ecs-<name>` with HTTPS on port 443 using a specified certificate and SSL policy, plus HTTP-to-HTTPS redirect on port 80, and optionally a test HTTPS listener on port 8443 and test HTTP-to-HTTPS redirect on port 8080; enable access logging to a designated S3 ... | resource "aws_lb" "ecs" {
count = var.alb ? 1 : 0
load_balancer_type = "application"
internal = false
name = "ecs-${var.name}"
subnets = var.public_subnet_ids
drop_invalid_header_fields = var.alb_drop_invalid_header_fields
enable_deletion... | DNXLabs/terraform-aws-ecs | Apache-2.0 | alb.tf | aws | [
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group",
"random_string"
] | 4494caf136224da671dc645fff742d0c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a single EC2 instance using the AMI, instance type, subnet ID, security group ID, and key pair name passed as variables, and tag it with a Name combining the provided name prefix and "-instance". | resource "aws_instance" "this" {
ami = var.instance.ami
instance_type = var.instance.type
# 明确由 env 层传入,无任何自动推断
subnet_id = var.subnet_id
vpc_security_group_ids = [var.sg_id]
key_name = var.keypair_name
tags = merge(var.tags, {
Name = "${var.name_prefix}-instance"
})
} | cloud-neutral-toolkit/iac_modules | Apache-2.0 | terraform-hcl-standard/aws-cloud/modules/ec2/main.tf | aws | [
"aws_instance"
] | 91c74aa9311aa1f8630ec35c083f10af |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Application Load Balancer in a specified VPC, fronting two EC2 instances running Amazon Linux 2023, each launched in a public subnet and assigned a public IP, with a security group allowing inbound HTTP (port 80) and SSH (port 22) traffic as defined by the ingress_rules variable, and configure the load balanc... | data "aws_ami" "amazon_linux" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["al2023-ami-*-x86_64"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
resource "aws_security_group" "web" {
name = "${var.project_name}-${var.environment... | cmorellh/aws-infra-tiers | MIT | tier-1-ec2/modules/webserver/main.tf | aws | [
"aws_instance",
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group",
"aws_lb_target_group_attachment",
"aws_security_group"
] | 4849c421b207650b89b072e515301e10 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `slsapp1-lambda-bucket` with public access blocked and automatic deletion of all contents on destroy, then upload a ZIP archive of the `lambda/hello-world` directory as `hello-world.zip`. Set up an IAM role named `slsapp1-lambda-role` that allows the Lambda service to assume it and attach the ... | terraform {
required_providers {
aws = {
source = "hashicorp/aws",
}
}
}
provider "aws" {
region = var.aws_region
}
resource "aws_s3_bucket" "lambda_bucket" {
bucket = "slsapp1-lambda-bucket"
# acl = "private"
force_destroy = true
}
data "archive_file" "lambda_hello_world"... | amitrke/aws-terraform-serverless | Apache-2.0 | main.tf | aws | [
"aws_apigatewayv2_api",
"aws_apigatewayv2_integration",
"aws_apigatewayv2_route",
"aws_apigatewayv2_stage",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_lambda_function",
"aws_lambda_permission",
"aws_s3_bucket",
"aws_s3_object"
] | 75801db03cf1e9c5fc75977f4e85afc0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Config rule named “elb-acm-certificate-required” that enforces all Elastic Load Balancers use SSL certificates issued by AWS Certificate Manager, and only enable this rule if the configuration flag `elb_acm_certificate_required.enabled` is set to true. | resource "aws_config_config_rule" "elb_acm_certificate_required" {
count = var.configuration.elb_acm_certificate_required.enabled ? 1 : 0
name = "elb-acm-certificate-required"
description = "This rule checks whether the Elastic Load Balancer(s) uses SSL certificates provided by AWS Certificate Manager. Yo... | geekcell/terraform-aws-config-rules | Apache-2.0 | modules/rules/lb/elb_acm_certificate_required.tf | aws | [
"aws_config_config_rule"
] | 4838bf04a91486f5427517a9ae3d24a0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Global Accelerator endpoint group with the specified listener ARN, region, health check settings (interval, path, port, protocol), threshold count, and traffic dial percentage; include endpoint configurations with their IDs and weights as provided; ensure the group is created before destroying any existin... | #---------------------------------------------------
# AWS globalaccelerator endpoint group
#---------------------------------------------------
resource "aws_globalaccelerator_endpoint_group" "globalaccelerator_endpoint_group" {
count = var.enable_globalaccelerator_endpoint_group ? 1 : 0
listener_arn = var.global... | SebastianUA/terraform | Apache-2.0 | aws/modules/globalaccelerator/globalaccelerator_endpoint_group.tf | aws | [
"aws_globalaccelerator_endpoint_group"
] | 6afc72759c994a9f22f6cd58b4aac750 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudFront distribution with a single origin pointing to an S3 bucket, configured to fetch content over HTTP only using TLSv1, allow GET and HEAD requests, cache nothing (all TTLs set to zero), forward all query strings and cookies, redirect viewers to HTTPS, apply no geographic restrictions, and use the defau... | resource "aws_cloudfront_distribution" "cloudfront" {
enabled = true
origin {
origin_id = var.origin_id
domain_name = var.bucket_domain_name
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "http-only"
origin_ssl_protocol... | LuisCarlosJp/DevOps_IaC_Docker | MIT | Modulo_IAC/AWS/modules/cloudfront/main.tf | aws | [
"aws_cloudfront_distribution"
] | 110160cf869ddc69b78782dff16fe393 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SNS topic named with the provided name prefix and environment tags, configure its policy to allow CloudWatch to publish messages only from the current AWS account, deploy a Lambda function named with the same prefix that sends Slack notifications using a webhook URL and channel passed as variables, grant the ... | # =============================================================================
# Notification Module - SNS + Lambda Slack 통합
# =============================================================================
# 목적: CloudWatch 알람을 Slack으로 전송하는 알림 시스템 구축
data "aws_region" "current" {}
data "aws_caller_identity" "current" {... | hyh528/PetClinic-AWS-Migration | Apache-2.0 | terraform/modules/notification/main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_cloudwatch_metric_alarm",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_lambda_function",
"aws_lambda_permission",
"aws_sns_topic",
"aws_sns_topic_policy",
"aws_sns_topic_subscription"
] | 2c8af7af0821c5c24606f0d30704df31 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `custom-role-<cluster_name>-kube-bench` that allows the `kube-bench` service account in the `kube-bench` namespace to assume the role via Kubernetes service account token authentication with EKS, attach a policy named `<cluster_name>-kube-bench-policy` that is generated from the `KubeBenchAWSSe... | data "aws_iam_policy_document" "kube_bench_assume_role" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "StringEquals"
variable = "${replace(aws_iam_openid_connect_provider.eks.url, "https://", "")}:sub"
values = ["system:serviceaccou... | homelabsz/homelabsz | WTFPL | terraform/accounts/production-services/setup-cloud/aws/4-setup-kubernetes/cluster/iam_role_kube_bench.tf | k8s | [
"aws_iam_policy",
"aws_iam_policy_attachment",
"aws_iam_role"
] | a67abaecae5838fa17dd00fa49fc1bc3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Store the ARN of the load balancer and the ID of its primary listener as SSM parameters under paths derived from the project name, specifically `/project-name/ecs/lb/id` and `/project-name/ecs/listener/id`. | resource "aws_ssm_parameter" "lb_arn" {
name = format("/%s/ecs/lb/id", var.project_name)
type = "String"
value = aws_lb.main.arn
}
resource "aws_ssm_parameter" "lb_listener" {
name = format("/%s/ecs/listener/id", var.project_name)
type = "String"
value = aws_lb_listener.main.id
} | jjasonhenrique/curso-containers-linuxtips | MIT | Day02-ECS/parameters.tf | aws | [
"aws_ssm_parameter"
] | e6e01a66ba742e56b98250102e9806c6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a PostgreSQL database instance named after the project, using version 16.1 on a db.t4g.micro instance with 20 GB of storage, listening on a configurable port, and seeded from the most recent existing snapshot of the same project if one exists; disable final snapshots on deletion, disable multi-AZ, ensure it is n... | # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/db_snapshot
data "aws_db_snapshot" "example" {
db_instance_identifier = local.project_name
most_recent = true
count = can(data.aws_db_snapshot.example[0].id) ? 1 : 0
}
# https://registry.terraform.io/prov... | kevinneuman/terraform-aws-ecs | MIT | rds.tf | aws | [
"aws_db_instance"
] | d1221fcd52dfd6c17b809f9e8c38875b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named after the project with `-iam-role-mng` suffix that allows EC2 instances to assume it, and attach the Amazon EKS worker node policy, Amazon ECR pull-only policy, and Amazon EKS CNI policy to that role. | resource "aws_iam_role" "vini_eks_role_mng" {
name = "${var.project_name}-iam-role-mng"
assume_role_policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Principal" : {
"Service" : "ec2.amazonaws.com"
},
"Action" : "sts:AssumeR... | viniquartz/terraform-study | MIT | terraform-aws-eks/modules/managed-node-group/role.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 0c69ba6729f01ccf2aacc65c09b051a3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named using the provided bucket name variable and the caller’s AWS account ID, set its ACL to private, and fully block all public access—including public ACLs, public policies, and public bucket access—by enabling all four public access blocking settings. |
# create a bucket
data "aws_caller_identity" "current" {}
resource "aws_s3_bucket" "current" {
bucket = "${var.bucket_name}-${var.parent_context.account_id}"
tags = {
Name = var.bucket_name
Description = var.description
Environment = var.common_tags.Environment
Creator = var.common_tags... | cfalguiere/salvia | Apache-2.0 | stages/labbench/terraform/modules/create_s3_bucket/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_acl",
"aws_s3_bucket_public_access_block"
] | 80e1e43ab2c297b50fd801c6c63f7693 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create one route per unique route table ID provided in the route_tables variable, each pointing the specified destination CIDR block through the given VPC peering connection ID, using the route table count from the variable if set, otherwise defaulting to the number of distinct route table IDs. | locals {
route_table_count = coalesce(
var.route_table_count,
length(distinct(var.route_tables))
)
}
resource "aws_route" "pcx_route_cidr" {
count = local.route_table_count
destination_cidr_block = var.destination_cidr
route_table_id = element(distinct(var.route_tabl... | rhythmictech/terraform-aws-pcx-route-cidr | MIT | main.tf | aws | [
"aws_route"
] | c7b1d9078ec22a5e6fbe1742394f59d7 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a KMS key named with the task name suffixed by "-kms-key" for encrypting S3 objects in the artifact and access logs buckets, with a 10-day deletion window, automatic key rotation enabled, and a policy granting the S3 service permission to use the key only for those specific buckets and the replication role permi... | resource "aws_kms_key" "s3kmskey" {
description = "KMS key for S3 bucket encryption"
deletion_window_in_days = 10
enable_key_rotation = true
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "EnableRootPermissions"
Effect = "Allow"
... | SpaceRocketDev/aws-app-platform | Apache-2.0 | modules/codepipeline/kms-key.tf | aws | [
"aws_kms_alias",
"aws_kms_key"
] | 35bd4a0dddd2c38dfe6a020811d9b7d9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named LLUK-VPC in us-east-1 with CIDR 10.0.0.0/16, enabling DNS support and hostnames. Provision three subnets within it: SubnetA (10.0.32.0/25), SubnetB (10.0.30.0/23), and SubnetC (10.0.33.0/28), all in us-east-1a, each configured to automatically assign public IP addresses to new instances. Launch two t... | # main.tf
provider "aws" {
region = "us-east-1"
}
resource "aws_vpc" "vpc_prinsipal" {
cidr_block = "10.0.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
tags = {
Name = "LLUK-VPC"
}
}
resource "aws_subnet" "subnetA" {
vpc_id = aws_vpc.vpc_prinsipal.id
cidr_block = "10... | QueDiusTet/optcloud | MIT | exercisis/pt1-3ex2/main.tf | aws | [
"aws_instance",
"aws_subnet",
"aws_vpc"
] | a799f1d85d0c88d4be86328baf1d93d0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Upload the local file `apple_utils.zip` to the S3 bucket named `apple_update_notification_bucket` with the key `apple_utils.zip`, ensuring integrity via MD5 checksum, and then create a Lambda layer named `apple_utils` using that S3 object as the deployment package, compatible with the Python runtime defined in `local.p... | resource "aws_s3_object" "lambda_layer_deployment_package_file" {
bucket = aws_s3_bucket.apple_update_notification_bucket.id
key = "apple_utils.zip"
source = "apple_utils.zip"
source_hash = filemd5("apple_utils.zip")
}
resource "aws_lambda_layer_version" "lambda_utils_layer" {
s3_bucket ... | cullancarey/apple_update_notification | MIT | terraform/lambda_layer.tf | aws | [
"aws_lambda_layer_version",
"aws_s3_object"
] | 1a263063d4d90cae391d7c5bedbe0d86 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an internet gateway for each VPC specified in the `vpc_igw` variable, attaching it to the corresponding VPC ID, and tag it with the project name followed by “-igw-” and the map key. | resource "aws_internet_gateway" "vpc_igw" {
for_each = var.vpc_igw
vpc_id = each.value.vpc_id
tags = merge(each.value.tags, {
Name = "${var.project_name}-igw-${each.key}"
})
} | vaibhav21soni/Terraform_EKS | MIT | modules/vpc/igw.tf | aws | [
"aws_internet_gateway"
] | ee30e5301822d062ec2315dd989b7c13 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC DHCP options set in the specified region with a custom domain name, DNS servers, IPv6 lease time, NTP servers, NetBIOS name servers, and NetBIOS node type, all configured via variables, and apply the provided tags. | resource "aws_vpc_dhcp_options" "this" {
region = var.region
domain_name = var.domain_name
domain_name_servers = var.domain_name_servers
ipv6_address_preferred_lease_time = var.ipv6_address_preferred_lease_time
ntp_servers = ... | ebogdum/terraform-providers | MIT | aws/resources/vpc_dhcp_options/main.tf | aws | [
"aws_vpc_dhcp_options"
] | 2da517b7a7070a2f699657ab4054b716 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named "terraform-bucket-sai" in the ap-south-1 region to store Terraform state, configure the AWS provider for ap-south-1, provision a number of EC2 instances (determined by a variable) using a variable-specified AMI and instance type, assign them to a security group named "terraform-default-sg" tha... | # Terraform state will be stored in S3
terraform {
backend "s3" {
bucket = "terraform-bucket-sai"
key = "terraform.tfstate"
region = "ap-south-1"
}
}
# Use AWS Terraform provider
provider "aws" {
region = "ap-south-1"
}
# Create EC2 instance
resource "aws_instance" "default" {
ami ... | adepollusaikumar/terraform | MIT | main.tf | aws | [
"aws_instance",
"aws_security_group"
] | d017d68ca008fa49e70ef4482127ef5e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a development EC2 instance named "bia-dev" in the us-east-1 region using the specified AMI and t3.micro instance type, assign it two security groups: one allowing unrestricted TCP access on port 3001 and full egress, and another permitting SSH access only from IP 177.181.191.222/32; attach it to a specific subne... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = "us-east-1"
profile = "bia"
}
resource "aws_security_group" "bia_dev" {
name = "bia-dev"
description = "access to bia-dev"
vpc_id = local.vpc_id
ingress {
... | prmacedoandrade/terraform_challenge | MIT | main.tf | aws | [
"aws_instance",
"aws_security_group"
] | 11c34ecddbf6dbcb8ed831ec0660a3ee |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named via a variable for ECS tasks to assume, granting it permissions to pull container images from ECR, write logs to CloudWatch, and optionally access SSM Parameter Store, with support for attaching optional AWS managed policies and custom policies for CloudWatch Logs, CloudWatch Agent, and additio... | # -----------------------------------------------------------------------------
# ECS Execution Role Module
# Creates the execution role used by ECS agent to:
# - Pull container images from ECR
# - Send logs to CloudWatch
# - Access SSM Parameter Store for secrets
#
# This is NOT the task role - that's used by your con... | llamandcoco/infra-modules | MIT | terraform/ecs-execution-role/main.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment"
] | 9912027d91944104a50e45b7f0b503ff |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a route table in the specified VPC with a dynamic set of routes defined by the `routes` variable, supporting CIDR blocks, internet gateways, NAT gateways, transit gateways, and VPC peering connections, and associate it with all subnets listed in the `subnet_ids` variable, tagging it with the provided name and an... | resource "aws_route_table" "this" {
vpc_id = var.vpc_id
dynamic "route" {
for_each = var.routes
content {
cidr_block = lookup(route.value, "cidr_block", null)
gateway_id = lookup(route.value, "gateway_id", null)
nat_gateway_id = lookup(route.value, "nat_gateway_id", null)
tr... | lace-cloud/registry-tf | MIT | modules/aws/vpc/route_table/main.tf | aws | [
"aws_route_table",
"aws_route_table_association"
] | ffb64f78c3c0a0243c3541dd2d013dd0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC in the ap-south-1 region with a CIDR block of 10.0.0.0/16, tag it with the environment name followed by "-vpc" (defaulting to "dev-vpc"), and configure Terraform to store its state in an S3 bucket named "dev-ops-state-manupa" under the key "vpc/terraform.tfstate" in the same region. |
resource "aws_vpc" "main" {
cidr_block = var.cidr
tags = {
Name="${var.env}-vpc"
}
}
variable "cidr" {
default = "10.0.0.0/16"
}
variable "env" {
default = "dev"
}
provider "aws" {
region = "ap-south-1"
}
terraform {
backend "s3" {
bucket = "dev-ops-state-manupa"
key = "vpc/terraform.tfs... | manupanand-freelance-developer/learn-github-actions | MIT | vpc/main.tf | aws | [
"aws_vpc"
] | a172505a4bcb5b2fd1753832de295b13 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Route 53 hosted zone named according to the project and environment (e.g., `myapp.example.com` for production or `myapp-staging.example.com` for non-production), or use an existing manually created hosted zone if specified; then create a single A record pointing the configured record name to the provided Appli... | resource "aws_route53_zone" "hosted_zone" {
count = var.create_hosted_zone == true ? 1 : 0
name = var.environment_full_name == "production" ? "${var.project}.${var.domain}" : "${var.project}-${var.environment_full_name}.${var.domain}"
tags = merge(
var.common_tags,
tomap(
{ "Name" = "${var.project... | nationalarchives/tdr-terraform-modules | MIT | route53/main.tf | aws | [
"aws_route53_record",
"aws_route53_zone"
] | 89dca0034489ac3b2002349697809f84 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “monitoring-vpc” with CIDR 10.2.0.0/16, enabling DNS hostnames and support, and attach an internet gateway named “monitoring-igw” to it. Provision two public subnets named “monitoring-public-subnet-1” and “monitoring-public-subnet-2” in the first two available availability zones, each with CIDR 10.2.... | # VPC Configuration for Monitoring Infrastructure
resource "aws_vpc" "monitoring_vpc" {
cidr_block = "10.2.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "monitoring-vpc"
Project = "monitoring-security"
}
}
# Internet Gateway
resource "aws_internet_gateway"... | moeinghaeini/aws | MIT | monitoringSecurity/infrastructure/vpc.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | bb65eb8fabcff52ccd3ce83d250209ef |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a public hosted zone in Route 53 for the domain specified in `var.domain_name`, set up an A record at the root of the domain pointing to the CloudFront distribution serving the main S3 bucket content, set up an A record for `www.` subdomain pointing to a separate CloudFront distribution serving the `www.`-prefix... | # Route 53 for domain
resource "aws_route53_zone" "main" {
name = var.domain_name
tags = var.common_tags
}
resource "aws_route53_record" "root-a" {
zone_id = aws_route53_zone.main.zone_id
name = var.domain_name
type = "A"
alias {
name = aws_cloudfront_distribution.root_s3_distr... | independentpixels/website-aws-s3-terraform-template | MIT | route53.tf | aws | [
"aws_route53_record",
"aws_route53_zone"
] | 5f56367a55646bd858ecd36f6cfa0435 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Application Load Balancer named nginx-ecs-test that listens on port 80 for HTTP traffic, routes all incoming requests to a target group also named nginx, and uses the default VPC’s subnets and a security group that allows HTTP access from the world. | # Create load balancer
resource "aws_lb" "nginx" {
name = "nginx-ecs-test"
load_balancer_type = "application"
security_groups = [aws_security_group.http_world.id]
subnets = data.aws_subnets.default.ids
}
# Create target group to connect services to
resource "aws_lb_target_group" "ng... | Ancient123/terraform-fargate-efs | Unlicense | load-balancer.tf | aws | [
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group"
] | 107321481f658e8472456d632751a130 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSM-managed jump host EC2 instance in a private subnet with no public IP, using Amazon Linux 2023, t3.micro size, and EBS encryption with the infrastructure KMS key; attach the instance to an IAM role with AmazonSSMManagedInstanceCore, AmazonSSMPatchAssociation, and a custom CloudWatch Logs policy; configure ... | #------------------------------------------------------------------------------
# Jump Host Module for ROSA Classic GovCloud
# Creates an SSM-enabled t3.micro EC2 instance for cluster access
# via port forwarding (no SSH keys or public IPs required)
#---------------------------------------------------------------------... | supernovae/rosa-tf | Apache-2.0 | modules/networking/jumphost/main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_iam_instance_profile",
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment",
"aws_instance",
"aws_security_group"
] | 38e2a17866d9e3bcd0421d63caff4253 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a WebSocket API named WebsocketStreamAPI that routes $connect and $disconnect requests to a single Lambda function named manager, configure the API to use the request body’s action field for route selection, deploy the API to a stage named after the API and a provided stage name, and grant the Lambda function pe... | data "aws_iam_policy_document" "lambda-assume-role-policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "lambda-logging-policy-doc" {
statement {
actions = [
"logs:Cre... | MrEthic/cse-finance-test | Apache-2.0 | terraform/modules/websocket/main.tf | aws | [
"aws_apigatewayv2_api",
"aws_apigatewayv2_deployment",
"aws_apigatewayv2_integration",
"aws_apigatewayv2_route",
"aws_apigatewayv2_stage",
"aws_iam_policy"
] | b13e5f176f25fb1aa7b4f7aa71808723 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an S3 bucket named `jumpt57-terraform-sandbox-tf-state` with versioning and AES256 encryption enabled, along with a DynamoDB table named `terraform-state-locking` for remote state locking; deploy two EC2 instances in the default VPC using a configurable AMI and instance type, each running a simple HTTP server... | terraform {
backend "s3" {
bucket = "jumpt57-terraform-sandbox-tf-state"
key = "tf-infra-basic/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-state-locking"
encrypt = true
}
required_providers {
aws = {
source = "hashicorp/aws... | jumpt57/terraform-sandbox | Apache-2.0 | basic/main.tf | aws | [
"aws_dynamodb_table",
"aws_instance",
"aws_lb",
"aws_lb_listener",
"aws_lb_listener_rule",
"aws_lb_target_group",
"aws_lb_target_group_attachment",
"aws_route53_record",
"aws_route53_zone",
"aws_s3_bucket",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning",
"aw... | 7323d4899b36fc4139426706a12560d9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudWatch log group named according to the `name` variable, retain logs for exactly 30 days, and tag it with both `Name` and `Instance` set to the same `name` variable value. | resource "aws_cloudwatch_log_group" "this" {
name = var.name
retention_in_days = 30
tags = {
Name = var.name
Instance = var.name
}
} | dyegoe/devops-challenge | Apache-2.0 | terraform/modules/ec2/cloudwatch.tf | aws | [
"aws_cloudwatch_log_group"
] | b17aee0efe3298868b01918cc732c80b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS task definition named using the cluster and service name variables, using the provided IAM role for both execution and task roles, with CPU and memory values set only when launching with Fargate, and configure a single container that pulls the specified image, uses the given CPU and memory, logs to a Clou... | resource "aws_ecs_task_definition" "default" {
count = var.image != "" ? 1 : 0
family = "${var.cluster_name}-${var.name}"
execution_role_arn = aws_iam_role.ecs_task.arn
task_role_arn = aws_iam_role.ecs_task.arn
requires_compatibilities = [var.launch_type]
network_mode = var.launch_type == "FARGATE"... | DNXLabs/terraform-aws-ecs-app-worker | Apache-2.0 | ecs-task-definition.tf | aws | [
"aws_ecs_task_definition"
] | 48c7464c14fc21530527ad3801b58a69 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a Bedrock model throughput with a specific commitment duration, model ARN, number of model units, and provisioned model name, using the region and tags provided as variables, and set the creation timeout to the value of the create_timeout variable. | resource "aws_bedrock_provisioned_model_throughput" "this" {
region = var.region
commitment_duration = var.commitment_duration
model_arn = var.model_arn
model_units = var.model_units
provisioned_model_name = var.provisioned_model_name
tags = var.t... | ebogdum/terraform-providers | MIT | aws/resources/bedrock_provisioned_model_throughput/main.tf | aws | [
"aws_bedrock_provisioned_model_throughput"
] | 9bdd01ed5b281ebd61c6c682a2aa1ac2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM group named according to the `group_name` variable, create multiple IAM users named according to the `user_names` list variable, assign each user to that group, and attach the ARNs listed in `group_policy_arns` to the group if the list is non-empty. | resource "aws_iam_group" "this" {
name = var.group_name
}
resource "aws_iam_user" "this" {
for_each = toset(var.user_names)
name = each.value
tags = var.default_tags
}
resource "aws_iam_user_group_membership" "membership" {
for_each = toset(var.user_names)
user = each.value
groups = [aws_iam... | FanoyG/terraform-aws-vpc-builder | MIT | modules/iam/main.tf | aws | [
"aws_iam_group",
"aws_iam_group_policy_attachment",
"aws_iam_user",
"aws_iam_user_group_membership"
] | d91a5b23afefd842fb5e9f91a11d2d47 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a multi-region CloudTrail trail named after the organization that logs all read and write API events to both an S3 bucket and a CloudWatch Logs group, enabled at the organization level with log file validation, and configure an IAM role and policy allowing CloudTrail to write logs to CloudWatch, using a KMS key ... | resource "aws_cloudtrail" "audit" {
count = var.cloudtrail ? 1 : 0
name = "${var.org_name}-cloudtrail"
s3_bucket_name = aws_s3_bucket.cloudtrail[0].id
is_multi_region_trail = true
enable_log_file_validation = var.enable_log_file_validation
is_organ... | DNXLabs/terraform-aws-audit-root | Apache-2.0 | cloudtrail.tf | aws | [
"aws_cloudtrail",
"aws_cloudwatch_log_group",
"aws_iam_role",
"aws_iam_role_policy"
] | baf991770c4071a36e40f3dc4c7a1617 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `render_node_role` that EC2 instances can assume, attach three policies granting full access to SQS, S3, and Auto Scaling (including permission to create the Auto Scaling service-linked role), and create an instance profile named `render_node_profile` associated with that role. | resource "aws_iam_role" "render_node_role" {
name = "render_node_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
re... | bholzer/AutoBlenderRender | MIT | modules/node_iam_role/main.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 4d9fe6c2088650ddd270f92a3143fc86 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a unique suffix using 16 random bytes, then look up the latest Amazon Linux AMI matching a variable-provided name filter, owned by either Amazon or the current AWS account, while also capturing the current AWS account ID and region for later use. | data "aws_caller_identity" "current" {
}
data "aws_region" "current" {
}
resource "random_id" "suffix" {
byte_length = 16
}
data "aws_ami" "latest_amazon_linux" {
most_recent = true
owners = ["amazon", data.aws_caller_identity.current.id]
filter {
name = "name"
values = [var.ami_name_filter]
}
... | KayakinCoder/filmdrop-learn | Apache-2.0 | modules/ssm_bastion/data.tf | aws | [
"random_id"
] | f3e16f45a670bc8e91dbdd92e8d7ed8a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a development VPC named siluryan-dev-vpc with a 10.42.0.0/16 CIDR block, including three public and three private subnets (10.42.10.0/24, 10.42.11.0/24, 10.42.1.0/24, and 10.42.2.0/24), an internet gateway attached to the VPC, separate route tables for public and private subnets with the public route table routi... | data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
owners = ["099720109477"] ... | Siluryan/ci-cd-studies | MIT | infra/instances/staging/main.tf | aws | [
"aws_default_network_acl",
"aws_default_security_group",
"aws_dynamodb_table",
"aws_instance",
"aws_internet_gateway",
"aws_route_table",
"aws_subnet",
"aws_vpc"
] | 3fc36d09623fed8f89c66033aef2dd4e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CrowdStrike Falcon sensor deployment automation using Systems Manager, storing credentials either in Secrets Manager (as a single secret with Cloud, ClientId, and ClientSecret fields) or in Parameter Store (as three separate SecureString parameters), and configure an association named “CrowdStrike-Sensor-Deplo... | locals {
falcon_cloud = lower(var.falcon_cloud)
secret_storage_method = lower(var.secret_storage_method)
cloud_mappings = {
us-1 = "api.crowdstrike.com"
us-2 = "api.us-2.crowdstrike.com"
eu-1 = "api.eu-1.crowdstrike.com"
}
secret_storage_method_mappings = {
parameterstore = "Paramet... | CrowdStrike/aws-ssm-distributor | MIT | official-package/terraform/modules/crowdstrike-distributor/main.tf | aws | [
"aws_secretsmanager_secret",
"aws_secretsmanager_secret_version",
"aws_ssm_association",
"aws_ssm_parameter"
] | 721369feb81adaa80e1c95d5eda2c936 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a public network load balancer named with the variable `name` plus `-master-lb-` and a short random suffix, backed by public subnets, with deletion protection disabled, and configure it to forward TCP traffic on port 6443 to EC2 instances in the main VPC using a target group named with `name` plus `-master-tg-` ... | resource "aws_lb" "k8s_master_lb" {
name = "${var.name}-master-lb-${random_string.short.result}"
internal = false
load_balancer_type = "network"
subnets = aws_subnet.public[*].id
enable_deletion_protection = false
tags = {
Name = "${var.name}-master-lb"
}
}
resour... | imgabrieldev/terraform-aws-self-managed-k8s | MIT | loadbalancer-controlplane.tf | aws | [
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group"
] | 9582038250a86cabfc38dbb3cffc5990 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two CodePipeline pipelines: one named using the `codepipeline_create_resources_name` variable to source infrastructure code from a CodeCommit repository’s main branch, run a CodeBuild plan stage, then run a CodeBuild apply stage; and another named using the `codepipeline_delete_resources_name` variable to source... | resource "aws_codepipeline" "codepipeline_create_resources" {
name = var.codepipeline_create_resources_name
role_arn = aws_iam_role.codepipeline-role.arn
# S3 bucket where CodePipeline will store its artifacts
artifact_store {
type = "S3"
location = aws_s3_bucket.s3-bucket-backend.bucket
}
... | g-ser/tf-aws-devtools | MIT | awsdevopstools/codepipeline.tf | aws | [
"aws_codepipeline"
] | 080105051e925a11b845cd8d0656b09b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.