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 S3 bucket named using a variable, configure it to serve a static website with `index.html` as the index document and `error.html` as the custom error page, upload `index.html`, `error.html`, and all `.jpg`, `.png`, and `.gif` files from a local `assets` directory into the bucket under the `assets/` prefix, se... | # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket
resource "aws_s3_bucket" "website_bucket" {
# S3 bucket naming rules
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
# Use this to assign a chosen bucket name
# bucket = var.bucket_name... | MPuersten/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"
] | c51042504273b0e489485ce93a128636 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy named after the instance variable with permissions to read SSM parameters, list and retrieve objects from any S3 bucket, and connect to any RDS database; attach this policy to an IAM role that EC2 instances can assume; and create an IAM instance profile named after the instance variable to attach t... | resource "aws_iam_policy" "ec2_policy" {
name = "${var.instance_name}-ec2-policy"
path = "/"
description = "Policy to provide permission to EC2"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow",
Action = [
"ssm:GetParameters",
... | rajayalamanchili/DataPipelines | MIT | mlflow_terraform_ec2/modules/ec2/iamrole.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | b2221bd54dddccd0c72879691df6fd5e |
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 IPv4 address space, enable DNS hostnames, and tag it with a name combining a prefix, the literal “-vpc-”, and the AWS region, plus an environment tag. Inside that VPC, provision a single subnet with a configurable CIDR block, tagged with a name combining a prefix and “-subnet”. Attach a... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
resource "aws_vpc" "space_coyote" {
cidr_block = var.address_space
enable_dns_hostnames = true
tags = {
name = "${var.prefix}-vpc-${var.region}"
environment = var.environment
}
}
resource "aws_... | tonydo6789/terraform-project | MIT | m8/space_coyote/networking/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 89ce12a21b9ff3c0372731e365fc91e3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision two t2.micro instances named dummy-server using the latest AMI matching the pattern dummy-server-* in the specified AWS region, with SSH (port 22) and the application port defined by the dummy_server_port variable open to all IP addresses, using the provided key pair and placing them in the default subnet of ... | provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.aws_region}"
}
data "aws_ami" "main_ami" {
most_recent = true
filter {
name = "name"
values = ["dummy-server-*"]
}
}
resource "aws_instance" "dummy-server" {
ami = "${data.aws_ami.ma... | m110/infrastructure-as-code | MIT | terraform/aws/main.tf | aws | [
"aws_instance",
"aws_security_group"
] | f8eecfa6a4d19817fc97ddb78d5efc98 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS service in the specified cluster with a name, desired count, and launch type defined by variables; attach zero or more load balancers to route traffic to specific containers and ports via provided target group ARNs; configure networking with optional public IP assignment, security groups, and subnets; opt... | #-----------------------------------------------
# AWS ECS Service
#-----------------------------------------------
resource "aws_ecs_service" "this" {
cluster = var.cluster
name = var.name
launch_type = var.launch_type
desired_count = var.min_count
task_definition = var.task_definition
... | Cloud-42/terraform-aws-ecs | Apache-2.0 | service/main.tf | aws | [
"aws_ecs_service"
] | d2546063df77fa8554e63be250af7998 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group named “firewall” in the VPC identified as `vpc_test` that allows all inbound traffic from any IPv4 address, specifically including ICMP ping requests, and permits all outbound traffic to any IPv4 address. | resource "aws_security_group" "firewall" {
name = "firewall"
description = "Allow icmp ping"
vpc_id = aws_vpc.vpc_test.id
ingress {
from_port = 0
protocol = "-1"
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 0
protocol = "icmp"
to_por... | maltez/devops_online | Apache-2.0 | homeworks/mihailov_sa/HW5/firewall.tf | aws | [
"aws_security_group"
] | 12721b50ab6dfc7026c45497d733e058 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS MQ broker configuration with a name derived from the environment and service name, using the specified engine type and version, and populate its configuration data from a provided template; ensure the configuration is created before any dependent resources and allow overriding the name, description, and t... | #---------------------------------------------------
# Create AWS MQ broker configuration
#---------------------------------------------------
resource "aws_mq_configuration" "mq_configuration" {
count = var.enable_mq_configuration ? 1 : 0
name = var.mq_configuration_name != "" ? var.mq_configuration_nam... | asrkata/SebastianUA-terraform | Apache-2.0 | aws/modules/mq/mq_configuration.tf | aws | [
"aws_mq_configuration"
] | 54744e4941d4618e3d90c0f2ec92244f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Gateway Load Balancer named according to the `gwlb_name` variable, attached to the subnets specified in `gwlb_subnet`, with a target group named per `gwlb_tg_name` that listens on port 6081 using GENEVE protocol, targets IP addresses from `instance_ip`, and performs TCP health checks on port 22, forwarding all... | # Copyright (c) 2022 Cisco Systems, Inc. and its affiliates
# All rights reserved.
#############################################################
# Resources
#############################################################
resource "aws_lb" "gwlb" {
name = var.gwlb_name
load_balancer_type = "gatew... | CiscoDevNet/terraform-aws-secure-firewall | Apache-2.0 | modules/gwlb/main.tf | aws | [
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group",
"aws_lb_target_group_attachment"
] | 4ac645badff4c0de5044f3cbce7297fb |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `kube_master` (prefixed with the value of `name_prefix` if provided) that can be assumed by EC2 instances, attach a policy to it named `kube_master` (with the same prefixing logic), and create an IAM instance profile named `kube_master` (also prefixed) that attaches the role to EC2 instances. | /**
* ## Kube Controller IAM
*
* Document.
*
*/
resource "aws_iam_role" "kube_master" {
name = "${var.name_prefix == "" ? "" : "${var.name_prefix}-"}kube_master"
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume.json
}
resource "aws_iam_role_policy" "kube_maste... | fpco/terraform-aws-foundation | MIT | modules/kube-controller-iam/main.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_role",
"aws_iam_role_policy"
] | f0fc600599d85c9b3baf64d37046c05c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM OpenID Connect provider configured to trust GitHub Actions, then create an IAM role that allows GitHub Actions workflows to assume it via `sts:AssumeRoleWithWebIdentity` with the audience condition set to `sts.amazonaws.com`, and attach a policy granting permission to call `sts:GetCallerIdentity` on any r... | provider "aws" {
region = var.region
}
# aws iam open id connect provider github
resource "aws_iam_openid_connect_provider" "provider" {
url = var.openid_url
client_id_list = var.client_id_list
thumbprint_list = var.thumbprint_list
tags = var.tags
}
resource "aws_iam_role" "role" {
name ... | SecurityRunners/CloudCommotion | Apache-2.0 | terraform/misconfigurations/aws_iam_role/oidc/main.tf | aws | [
"aws_iam_openid_connect_provider",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | cf0baa2c954492f93c7861286ea99a8e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Launch a single t3.micro Amazon Linux 2023 instance in the first application subnet with no public IP, attached to a specified security group, that installs and starts Apache HTTP Server, serves a page identifying it as part of the app tier, and registers it as a target on a pre-defined load balancer target group liste... | data "aws_ami" "amazon_linux" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["al2023-ami-*-x86_64"]
}
}
resource "aws_instance" "app" {
ami = data.aws_ami.amazon_linux.id
instance_type = "t3.micro"
subnet_id ... | Nisha318/cloud-network-segmentation | MIT | infra/terraform/modules/app_ec2/main.tf | aws | [
"aws_instance",
"aws_lb_target_group_attachment"
] | 9924fef68b4884d39cca2f6dc6349ec3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a single t2.micro Amazon EC2 instance in the us-west-2 region using the most recent Ubuntu 20.04 LTS (Focal Fossa) 64-bit server AMI owned by Canonical, and tag it with the name "HelloWorld". | provider "aws" {
version = "2.65.0"
region = "us-west-2"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}
owners = ["099720109477"]
}
resource "aws_instance" "helloworld" {
ami = data.aws_am... | sedatkan/jenkinsterrafromaws | Apache-2.0 | main.tf | aws | [
"aws_instance"
] | 9526015f897c4cba0dbc7f10b6064b2b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a bastion host using the latest Amazon Linux 2 ARM64 AMI, with an instance type, key pair, and public IP address determined by variables; place it in a specified public subnet, attach a security group that allows SSH access from anywhere, and create a Route 53 A record pointing the bastion domain to the insta... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
data "aws_ami" "linux" {
owners = ["amazon"]
executable_users = ["all"]
most_recent = true
filter {
name = "name"
values = ["amzn2-ami-hvm-*"]
}
filter {
name = "architecture"
valu... | purpozedgmbh/aws-ssh-tunnel | MIT | main.tf | aws | [
"aws_instance",
"aws_route53_record",
"aws_security_group"
] | 2d6b47e7faa949b59bd41f15e2361f80 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EC2 key pair named “mykey” using the public key from the file path provided in the `PATH_TO_PUBLIC_KEY` variable, ignoring any future tag changes to it, and launch a number of t2.micro instances equal to the value of `instance_count`, each using the AMI mapped to the current AWS region, named sequentially as ... | resource "aws_key_pair" "mykey" {
key_name = "mykey"
public_key = file(var.PATH_TO_PUBLIC_KEY)
lifecycle {
ignore_changes = [tags]
}
}
resource "aws_instance" "example" {
count = var.instance_count
ami = lookup(var.AMIS, var.AWS_REGION)
instance_type = "t2.micro"
key_name =... | Finfra/awsTerraform-course | MIT | c0-MultiInstance/instance.tf | aws | [
"aws_instance",
"aws_key_pair"
] | a3b3aa6c6091f1c53993306c8416e62b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create listener rules on both the public and internal Application Load Balancers to forward traffic to environment-specific target groups based on configurable path patterns, host headers, source IP ranges, and custom HTTP headers; also create redirect rules for hostnames and paths to enforce HTTPS redirects with HTTP ... | resource "aws_lb_listener_rule" "green" {
for_each = {for t in local.target_group_types : t => t}
listener_arn = strcontains(each.key, "internal") ? var.internal_alb_listener_arn : var.alb_listener_https_arn
action {
type = "forward"
target_group_arn = aws_lb_target_group.green[each.key].arn
... | DNXLabs/terraform-aws-ecs-app | Apache-2.0 | alb-target-group.tf | aws | [
"aws_lb_listener_rule",
"aws_lb_target_group",
"random_string"
] | fea6dc83eedf9cb4f78d3556f6fd6439 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudWatch dashboard named after the project and stage that displays Lambda and API Gateway metrics: Lambda invocations and errors, duration (average, max, min), concurrent executions, and throttles; API Gateway requests, 4XX and 5XX errors, and latency (average and p99); a calculated Lambda error rate percent... | resource "aws_cloudwatch_dashboard" "main" {
dashboard_name = "${var.project_name}-${var.stage}"
dashboard_body = jsonencode({
widgets = [
# Lambda Invocations
{
type = "metric"
x = 0
y = 0
width = 12
height = 6
properties = {
metrics... | teurajarvi/listservice | MIT | infra/modules/dashboard/main.tf | aws | [
"aws_cloudwatch_dashboard"
] | a9d9c575177b1e30ab62c1739c38831a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SNS topic named “original_topic” in the master region, and subscribe an SQS queue named “original_queue” to it using the SQS protocol. | resource "aws_sns_topic" "original_topic" {
provider = aws.master_region
name = "original_topic"
}
resource "aws_sns_topic_subscription" "original_topic_queue_subscription" {
provider = aws.master_region
endpoint = aws_sqs_queue.original_queue.arn
protocol = "sqs"
topic_arn = aws_sns_topic.original_topic... | ZRRero/aws-exercises | MIT | exercises/messaging/sqs/create_sns_sqs_with_dlq/solution/code/terraform/sns.tf | aws | [
"aws_sns_topic",
"aws_sns_topic_subscription"
] | b6d8f5edfc611dd61cc6c14d22508bac |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket to host a static website, configure CORS rules for it, and set up a bucket policy that grants CloudFront read access only when requests originate from a specific CloudFront distribution. Provision a Lambda@Edge function using Node.js 20.x to redirect requests to index.html, attach an IAM role and po... | locals {
s3_origin_id = var.bucket_name
lambda_qualified_arn = "${aws_lambda_function.redirect.arn}:${aws_lambda_function.redirect.version}"
}
# Create an S3 bucket for hosting the static website
resource "aws_s3_bucket" "my_bucket" {
bucket = var.bucket_name
tags = var.tags
}
resource "aws_s3_bucke... | rpstreef/terraform-static-site | Apache-2.0 | modules/s3-static-site/main.tf | aws | [
"aws_cloudfront_distribution",
"aws_cloudfront_function",
"aws_cloudfront_origin_access_control",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_lambda_function",
"aws_route53_record",
"aws_s3_bucket",
"aws_s3_bucket_cors_configuration",
"aws_s3_bucket_policy"
] | 029d73d08861e555e6a728a0d1ec5bfb |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM instance profile for a GraphDB EC2 instance with a role that allows it to assume the role, attach AWS-managed CloudWatch and SSM policies, and grant permissions to describe and manage EC2 volumes (including creation with specific tags), tag resources, interact with SSM parameters under a specific prefix, ... |
locals {
assume_role_principal_arn = var.assume_role_principal_arn != null ? var.assume_role_principal_arn : data.aws_caller_identity.current.arn
}
resource "aws_iam_instance_profile" "graphdb_iam_instance_profile" {
name_prefix = "${var.resource_name_prefix}-instance-profile"
role = aws_iam_role.graphdb... | Ontotext-AD/terraform-aws-graphdb | Apache-2.0 | modules/graphdb/iam.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment"
] | 884a26b2185aa11bf64412d0a3cc090d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `www.<domain>` with public read access enabled, website hosting configured to serve `index.html` as the index and `error.html` as the error page, and a second S3 bucket named `<domain>` that redirects all requests to `https://www.<domain>`, with both buckets explicitly allowing public access b... | # Create the S3 bucket for the www domain
resource "aws_s3_bucket" "bucket_www" {
bucket = "www.${var.domain}"
}
resource "aws_s3_bucket_public_access_block" "bucket_www_public_access" {
bucket = aws_s3_bucket.bucket_www.id
block_public_acls = false
block_public_policy = false
ignore_public_acls ... | grahil-24/Terraform-AWS-Static-IAAC | MIT | modules/s3/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_website_configuration"
] | ea527101a3b82f47deb9e8fb8a06868a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a private subnet in the specified VPC and availability zone with a CIDR block and name, tag it as “private” and merge in any additional tags; provision a NAT Gateway in a designated public subnet with an associated Elastic IP, name it “main-nat-gateway”; create a route table for the private subnet that routes al... | resource "aws_subnet" "subnet" {
vpc_id = var.vpc_id
cidr_block = var.cidr_block
availability_zone = var.availability_zone
tags = merge(
{
Name = var.name,
kind = "private"
},
var.tags
)
}
# Internet for private subnets
# Elastic IP for NAT Gateway
resource "aws_ei... | rafikbahri/aws-bastion-architecture | MIT | modules/aws-private-subnet/main.tf | aws | [
"aws_eip",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet"
] | ac25e8d1930432688e177af40ef8c528 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `ddt-networking-XXXXX` (with a random 5-digit suffix) and another named `ddt-application-XXXXX`, both with versioning enabled, private ACL, and force destroy behavior; set up a DynamoDB table named `ddt-tfstatelock` with 20 read and 20 write capacity units to serve as a Terraform state lock; p... | ##################################################################################
# VARIABLES
##################################################################################
variable "aws_access_key" {}
variable "aws_secret_key" {}
variable "region" {
default = "us-east-1"
}
variable "aws_networking_bucket" {
... | raduceaca1234/Terraform-Deep-Dive | MIT | module5/1-prerequisites/remotestate.tf | aws | [
"aws_dynamodb_table",
"aws_iam_access_key",
"aws_iam_group",
"aws_iam_group_membership",
"aws_iam_group_policy_attachment",
"aws_iam_user",
"aws_iam_user_policy",
"aws_s3_bucket",
"random_integer"
] | 75d110e272fca2848a55dedadcf52a17 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with CIDR 10.0.0.0/16 and a single subnet 10.0.1.0/24 within it, named “Introduction”. Set up a security group named “introduction-sg” that allows inbound TCP traffic on port 80 from any IPv4 address. Configure an IAM role named “intro-role” assumable by EC2, attach to it a policy named “intro-policy” gran... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = "us-east-1"
}
############################################
# VPC + SUBNET
############################################
resource "aws_vpc" "intro" {
cidr_block = "10.0.0.0/16"
tags = { Name = "Int... | ooluwgb/HashiCorp-Terraform-Professional-Prep | MIT | Part_0_Introduction/examples/aws.tf | aws | [
"aws_autoscaling_group",
"aws_iam_instance_profile",
"aws_iam_policy",
"aws_iam_policy_attachment",
"aws_iam_role",
"aws_instance",
"aws_launch_template",
"aws_s3_bucket",
"aws_s3_object",
"aws_security_group",
"aws_subnet",
"aws_vpc",
"aws_vpc_security_group_ingress_rule",
"random_id"
] | cc7f337c4df53be1e21f6a57ffaf1f20 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECR repository for each name listed in the `repository_names` variable, with automatic deletion of images when the repository is destroyed, AES256 encryption for stored images, mutable image tags, and tags including the repository name, the project name "Pharmakart", and "ManagedBy" set to "Terraform". | resource "aws_ecr_repository" "ecrs" {
for_each = toset(var.repository_names)
name = each.value
force_delete = true
encryption_configuration {
encryption_type = "AES256"
}
image_tag_mutability = "MUTABLE"
tags = {
Name = each.value
Project = "Pharmakart"
ManagedBy = "Te... | PharmaKart/cloud-config | MIT | infrastructure/modules/ecr/main.tf | aws | [
"aws_ecr_repository"
] | 88ecc6087b8e7c1d57a8482a93501f76 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create three private subnets in the eu-west-2 region, one in each availability zone (a, b, and c), all within the VPC identified by the Name tag provided via the vpc_name variable, with each subnet allocated a /27 CIDR block starting at the 160, 192, and 224 addresses respectively, and name each subnet using the patter... | # Fetch VPC ID based on its Name tag
data "aws_vpcs" "filtered_vpcs" {
filter {
name = "tag:Name"
values = [var.vpc_name]
}
}
data "aws_vpc" "selected" {
id = data.aws_vpcs.filtered_vpcs.ids[0]
}
# Create Subnet in Availability Zone A
resource "aws_subnet" "subnet_a" {
vpc_id = data.aws_v... | UKHomeOffice/core-cloud-ingress-terraform | MIT | modules/ingress/private-subnets/main.tf | aws | [
"aws_subnet"
] | acc62c5a00f7117aa1c87f851181f50d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two ACM certificates—one for a generic subdomain (e.g., `app.example.com`) and one for a region-specific subdomain (e.g., `us-east-1.app.example.com`)—each with DNS validation records in the appropriate Route 53 hosted zones, and configure DNS records including SOA and NS records for both the generic and regiona... | locals {
live_env = var.environment == "np" ? "dev" : "production"
soa_region_ns = var.region == "us-east-1" ? var.generic_primary_region_domain.name_servers : var.generic_secondary_region_domain.name_servers
current_region_domain = var.region == "us-east-1" ? var.generic_primary_region_domai... | rsalus/terraform-projects | MIT | passthrough-service/terraform/region/dns/route53.tf | aws | [
"aws_acm_certificate",
"aws_acm_certificate_validation",
"aws_route53_record"
] | e4af9ee5a8e8df376f12564344f68f7e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy named `<name>-server-policy` that grants a Vault server running on EC2 permissions to fully manage a specific DynamoDB table, encrypt and decrypt data with a specific KMS key, and manage two named Secrets Manager secret patterns (`cicd-vault-<workspace>-token*` and `vault-secret-init-*`). Attach th... | resource "aws_iam_policy" "vault_server_policy" {
name = "${local.name}-server-policy"
description = "Vault server policy to access DynamoDB, KMS and Secrets Manager"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"dynamodb:DescribeLimits",
... | red-devops/Workout-recorder-vault | MIT | 100-app-infra/140-vault-instance/iam.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_policy",
"aws_iam_policy_attachment",
"aws_iam_role"
] | 0ab2958e42a8ed46ca4e24a1f763b519 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a single bastion host in the specified VPC subnet, using either a provided Amazon Linux 2 AMI ID or automatically fetching the latest compatible Amazon Linux 2 AMI, with an instance type defined by the variable, configured to allow all outbound traffic, assigned a security group named after the VPC with the r... | # Bastion host (optional)
# Fetch latest Amazon Linux 2 AMI if no explicit bastion_ami_id provided
data "aws_ami" "bastion" {
count = var.bastion_enabled && var.bastion_ami_id == "null" ? 1 : 0
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-... | mdefenders/terraform-aws-infra | MIT | main.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_instance",
"aws_security_group"
] | 28b8deb2abcbf9575aadbf7dda457e36 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a subnet in the specified VPC with the given IPv4 and IPv6 CIDR blocks, availability zone, and configurable public IP assignment on launch; optionally create a new route table for the subnet and associate it, or associate the subnet with an existing route table if provided; if the subnet is public, add a route t... | resource "aws_subnet" "main" {
vpc_id = var.vpc_id
cidr_block = var.cidr_block
availability_zone = var.availability_zone
# IPv6 Configuration
ipv6_cidr_block = var.ipv6_cidr_block
assign_ipv6_address_on_creation = var.assign_ipv6_address_on_creation
# Public IP Configur... | juspay/hyperswitch-suite | Apache-2.0 | terraform/aws/modules/base/subnet/main.tf | aws | [
"aws_nat_gateway",
"aws_route",
"aws_route_table",
"aws_route_table_association",
"aws_subnet"
] | 3c5fb7baefac0eada12fb7ad553e4209 |
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 configurable name, enable versioning, block all forms of public access (including public ACLs, policies, and bucket restrictions), optionally configure CORS rules if provided, and optionally attach a custom bucket policy while ensuring the public access block is applied first. | # S3 Bucket Module
resource "aws_s3_bucket" "this" {
bucket = var.bucket_name
force_destroy = var.force_destroy
tags = merge(
var.tags,
{ Name = var.bucket_name }
)
}
resource "aws_s3_bucket_versioning" "this" {
bucket = aws_s3_bucket.this.id
versioning_configuration {
status = var.ve... | zfael/tfm | MIT | modules/aws/s3-bucket/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_cors_configuration",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_versioning"
] | 3a94f346ff60d2d037f6a87c4057e0f7 |
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 project with a trailing hyphen, associated with the VPC whose ID is stored in the SSM parameter `/vpc/id`, allowing all outbound traffic to any destination, and allowing all inbound traffic only from the 10.0.0.0/16 subnet range with a Portuguese description indicating it opens t... | resource "aws_security_group" "main" {
name = format("%s-", var.project_name)
vpc_id = data.aws_ssm_parameter.vpc.value
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_security_group_rule" "subnet_ranges" {
type = "ingres... | cquinta/ecs-cluster | Apache-2.0 | sg.tf | aws | [
"aws_security_group",
"aws_security_group_rule"
] | b88821b56fc378614a7f64b706063ce0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named using the component name with a 10.0.0.0/16 CIDR block, enabling DNS hostnames and support; deploy public and private subnets across all available Availability Zones, assigning each a specific CIDR block and naming them with the component name and subnet type; attach an internet gateway to the VPC, p... | data "aws_availability_zones" "available" {
state = "available"
}
resource "aws_vpc" "jenkins" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = local.component_name
}
}
# subnets
resource "aws_subnet" "jenkins_pub" {
for_each = toset(loc... | devhalos/nihil-jenkins | MIT | jenkins-service/terraform/vpc.tf | aws | [
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | aad5cfb1d75ea61dbcc57e28f5d263b4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Set a hard limit on the number of VPCs per region using the AWS Service Quotas API, with the limit value controlled by a variable named `vpc_quota`, to prevent unauthorized or excessive VPC creation that could lead to cost overruns or security risks. | # To enforce a limit on VPCs to prevent "Shadow IT" or cost runaway
resource "aws_servicequotas_service_quota" "vpc_limit" {
quota_code = "L-F678F1CE" # Quota code for VPCs per region
service_code = "vpc"
value = var.vpc_quota
} | Ayush-cloud06/aws-secure-landing-zone | Apache-2.0 | modules/quotas/main.tf | aws | [
"aws_servicequotas_service_quota"
] | 3b83ea8002d0b56804af4a5ad9257e2b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Route 53 record for autodiscover pointing to the Amazon WorkMail autodiscover endpoint, add one or more DKIM CNAME records for domain verification with Amazon SES, set the domain’s MX record to route email through Amazon SES, create a TXT record for SES domain verification, and add any extra DNS records specif... | resource "aws_route53_record" "autodiscover" {
name = "autodiscover.${var.domain}"
records = [
"autodiscover.mail.${var.region}.awsapps.com.",
]
ttl = var.ttl
type = "CNAME"
zone_id = var.zone_id
}
resource "aws_route53_record" "domain_keys" {
count = local.domain_key_prefixes_count
name = ... | QuiNovas/terraform-aws-workmail-route53 | Apache-2.0 | main.tf | aws | [
"aws_route53_record"
] | c3b6447b2c5728ea649a09634f641a33 |
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 Owner and Project tags with versioning enabled and AES256 server-side encryption, and a DynamoDB table named with the same Owner and Project tags for Terraform state locking, using on-demand billing with a single string attribute named LockID as the primary key, all deployed in the u... | provider "aws" {
region = "us-west-2"
}
resource "aws_s3_bucket" "terraform_state" {
bucket = "${local.tags.Owner}-${local.tags.Project}-terraform-state"
lifecycle {
prevent_destroy = false
}
tags = local.tags
}
resource "aws_s3_bucket_versioning" "terraform_state" {
bucket = aws_s3_bucket.terraform... | vti-do2402/infra-provisioning | MIT | backend/main.tf | aws | [
"aws_dynamodb_table",
"aws_s3_bucket",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning"
] | bc8684e84d1c27180dd2f2b8f57e9103 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EC2 instance using the latest Amazon Linux 2023 AMI (or a specified AMI ID), with configurable instance type, subnet, and key pair; provision a dedicated security group with flexible ingress and egress rules defined per CIDR block, or reuse existing security groups; optionally create an IAM role and instance ... | ########## Data Sources ##########
###################################
# AWS partition (for GovCloud/China support)
data "aws_partition" "current" {}
# Get latest Amazon Linux 2023 AMI via SSM parameter
data "aws_ssm_parameter" "ami" {
count = var.ami_id == null ? 1 : 0
name = var.ami_ssm_parameter
}
locals {
... | nurwandi/terraform-aws-starter | MIT | modules/ec2/main.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_instance",
"aws_security_group",
"aws_vpc_security_group_egress_rule",
"aws_vpc_security_group_ingress_rule"
] | f3be4f7d265f605263eee3db4ae33f37 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an origin access control for CloudFront with a configurable name, origin type, signing behavior, and signing protocol, and provision exactly one instance only when the origin_access_control variable is provided. | resource "aws_cloudfront_origin_access_control" "default" {
count = var.origin_access_control != null ? 1 : 0
name = var.origin_access_control["name"]
origin_access_control_origin_type = var.origin_access_control["origin_type"]
signing_behavior = var.origin_access_c... | leonmwandiringa/terraform-aws-cloudfront | Apache-2.0 | origin-access-control.tf | aws | [
"aws_cloudfront_origin_access_control"
] | 3ccad9979eff063a869df11254c5084c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `logs-to-opensearch-lambda` that can be assumed by the Lambda service, attach a policy to it that grants permissions to create and write to CloudWatch Logs resources and manage EC2 network interfaces, and ensure the role is not automatically detached from any policies when updated. | resource "aws_iam_role" "logs_to_opensearch" {
name = "logs-to-opensearch-lambda"
path = "/"
force_detach_policies = false
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.am... | mattermost/mattermost-cloud-monitoring | Apache-2.0 | aws/logs-to-opensearch/iam.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy"
] | e73ca017c9fff55b84f6b0073d5d476b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role with a configurable name, description, and assume role policy document; create a separate IAM policy with a configurable name, description, and policy document; and attach the policy to the role. | # Role
resource "aws_iam_role" "role" {
name = var.role_name
description = var.role_description
assume_role_policy = var.assume_role_policy
}
# Policy
resource "aws_iam_policy" "policy" {
name = var.policy_name
description = var.policy_description
policy = var.policy
}
# R... | mmdcloud/aws-medical-chatbot | Apache-2.0 | terraform/modules/iam/main.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 6b10930a8ad9e6317e92a9691e730de7 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two weighted Route 53 A records for the same DNS name, one primary and one secondary, each routing traffic to a specific regional API Gateway domain based on weights defined in a routing map keyed by region, with health evaluation enabled for both. | resource "aws_route53_record" "primary" {
zone_id = var.route53_hosted_zone
name = var.api_dns_name
type = "A"
weighted_routing_policy {
weight = lookup(var.routing, var.region)
}
set_identifier = "primary"
alias {
evaluate_target_health = true
name = data.aws_api_gate... | jeansemolini/linuxtips-curso-containers-aws-multiregion-sales-api-gateway | MIT | post-deployment/route53.tf | aws | [
"aws_route53_record"
] | 5e72561026aeb9c0c19202993f684e10 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a t2.micro EC2 instance in the eu-west-1 region using AMI ami-028188d9b49b32a80, with a security group named server-security-group that allows inbound SSH (port 22) and HTTP (port 80) traffic from any IP address, full outbound access, and uses the public key named javier for SSH access; execute the contents o... | provider "aws" {
region = "eu-west-1"
}
data "template_file" "start_script" {
template = "${file("./script.sh")}"
}
resource "aws_security_group" "server_sg" {
name = "server-security-group"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0... | jortizfdez/cloudlab | MIT | deployment/main.tf | aws | [
"aws_instance",
"aws_security_group"
] | 0b459d7f37c02258c75df6f0c2ee79da |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSM Parameter Store entry for the primary endpoint address of an ElastiCache replication group, another for its reader endpoint, one for the port, and a fourth for the password only if encryption is enabled—each parameter named using the tenant, project, and environment variables, tagged with Name, Tenant, Pr... | resource "aws_ssm_parameter" "main_redis_primary" {
name = "/${var.tenant}/${var.name}/${var.environment}/elasticache/${var.cache_name}/primary"
description = "Managed by Magicorn"
type = "SecureString"
value = aws_elasticache_replication_group.main.primary_endpoint_address
tags = {
N... | magicorntech/terraform-aws-elasticache | MIT | ssm.tf | aws | [
"aws_ssm_parameter"
] | 37dcd41402cbe64579d19dbbe7c78e80 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a single Amazon Linux 2 virtual machine in the ap-south-1 region using the latest Amazon-provided AMI matching the name pattern `amzn2-ami-hvm-*-x86_64-gp2`, with virtualization type HVM, deployed as a t2.micro instance in subnet `subnet-09d40a18231fa204c` with security group `sg-0fe159676c4ddc32b`, and tag i... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = "ap-south-1"
}
# Fetch latest Amazon Linux 2 AMI
data "aws_ami" "amazon_linux" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_6... | NishanthPudota/aws-terraform-built | MIT | main.tf | aws | [
"aws_instance"
] | 6e80170eed422627993a30ebf985f1c0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with DNS hostnames and support enabled, using a configurable CIDR block and tagged with the project name and environment. Provision an internet gateway attached to the VPC, and deploy one public and one private subnet per availability zone—public subnets should auto-assign public IP addresses on launch, wh... | # AWS VPC
resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "${var.project_name}-vpc-${var.environment}"
Environment = var.environment
Project = var.project_name
}
}
# Internet Gateway
resource "aw... | dsingh32/multi-cloud-infrastructure | MIT | terraform/modules/networking/aws/main.tf | aws | [
"aws_db_subnet_group",
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | afc6e6807a586184fe30e243349f6798 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “ai-video-lab-vpc” in us-east-1 with DNS support and hostnames enabled, an Internet Gateway attached to it, a public subnet with automatic public IP assignment, and a private subnet—then configure routing so the public subnet routes all traffic through the Internet Gateway and the private subnet rout... | provider "aws" {
region = "us-east-1"
}
# Create the VPC
resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr
enable_dns_support = true
enable_dns_hostnames = true
tags = {
Name = "ai-video-lab-vpc"
}
}
# Create an Internet Gateway
resource "aws_internet_gateway" "igw" {
vpc_id = aws_v... | acanave/terraform-ai-image-lab | MIT | terraform/modules/vpc/vpc.tf | aws | [
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | e747926a2a55b24c94227a2480d4dda5 |
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 `gitlab.example.com` (where `example.com` is the domain of the hosted zone) pointing to the public IP of the `gitlab_server` EC2 instance, with a TTL of 300 seconds. | ### Gitlab A Record
resource "aws_route53_record" "record" {
zone_id = data.aws_route53_zone.my_zone.zone_id
name = "gitlab.${data.aws_route53_zone.my_zone.name}"
type = "A"
ttl = "300"
records = [aws_instance.gitlab_server.public_ip]
} | nazy67/terraform_gitlab_project | MIT | route_53_record.tf | aws | [
"aws_route53_record"
] | 927ef5315261b247ef29da2f8e432dbf |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CI/CD pipeline named after the project that pulls source code from a specified GitHub repository branch named “master” using a CodeStar Connections connection, stores pipeline artifacts in a designated S3 bucket encrypted with a specific KMS key, and dynamically adds stages based on a provided list of stage co... | #This solution, non-production-ready template describes AWS Codepipeline based CICD Pipeline for terraform code deployment.
#© 2023 Amazon Web Services, Inc. or its affiliates. All Rights Reserved.
#This AWS Content is provided subject to the terms of the AWS Customer Agreement available at
#http://aws.amazon.com/agree... | collinsefe/aws-secured-pipelines | MIT-0 | modules/codepipeline/main.tf | aws | [
"aws_codepipeline",
"aws_codestarconnections_connection"
] | 9b1488af10a1f87b31bb5ffd08e1de4e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two customer-managed KMS keys in the current AWS account: one named “s3-tfstate-kms” with a 30-day deletion window, automatic key rotation enabled, and an alias “alias/s3-tfstate-kms” for encrypting Terraform state stored in S3; and another named “s3-logs-kms” with identical settings and an alias “alias/s3-logs-... | # KMS key for S3 bucket
data "aws_caller_identity" "current" {}
# IAM policy document for KMS key
resource "aws_kms_key" "s3_state" {
description = "KMS key for S3 bucket"
deletion_window_in_days = 30
enable_key_rotation = true
policy = data.aws_iam_policy_document.kms_s3_state.json
tags = ... | kieukhang185/devopskit | MIT | iac/envs/dev/bootstrap-s3/kms.tf | aws | [
"aws_kms_alias",
"aws_kms_key"
] | 9126078a24cd7f22888181a8464dcb1c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Security Hub custom action target in the specified region with the given name, identifier, and description. | resource "aws_securityhub_action_target" "this" {
region = var.region
name = var.name
identifier = var.identifier
description = var.description
} | ebogdum/terraform-providers | MIT | aws/resources/securityhub_action_target/main.tf | aws | [
"aws_securityhub_action_target"
] | 1606dda346e08fa7dbc49229ab0df48f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy named “S3_Access” that grants permission to list all buckets, list a bucket’s contents, retrieve objects, and get bucket location for the S3 buckets whose ARNs are provided via the `s3_arns` variable, and ensure this policy is created only after the `s3_access` IAM group exists. | resource "aws_iam_policy" "s3_access_policy" {
name = "S3_Access"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
# This
policy = jsonencode({
"Version" = "2012-10-17",
"Statement" = [
{
"Sid" : "",
"Effect" : "Allow",
... | Cyber-Duck/terraform-aws-s3-access | Apache-2.0 | policy.tf | aws | [
"aws_iam_policy"
] | 8c82bc7e4b030f5808f603a676c55767 |
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 for the domain specified in `var.dns["domain_name"]`, and for each subdomain listed in `var.subdomains`, add an NS record in that hosted zone pointing to the provided name servers with the subdomain’s specified TTL. Output the hosted zone’s name servers and its ID. | locals {
common_tags = {}
}
resource "aws_route53_zone" "root" {
name = var.dns["domain_name"]
tags = merge(local.common_tags, var.custom_tags)
}
resource "aws_route53_record" "ns_in_parent" {
count = length(var.subdomains)
zone_id = aws_route53_zone.root.zone_id
name = var.subdomains[count.index]["... | clusterfrak-dynamics/terraform-aws-route53 | Apache-2.0 | root/dns.tf | aws | [
"aws_route53_record",
"aws_route53_zone"
] | 38f8db52d5a6d58a3652b5c48f935d7d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudWatch Events rule named after the Lambda function with a custom event pattern, configure it to invoke a specific Lambda function, and grant the CloudWatch Events service permission to invoke that Lambda. | resource "aws_cloudwatch_event_rule" "event_rule" {
name = "${var.lambda_name}-cw-event"
description = "This CW Event Triggers the Lambda: ${var.lambda_name}"
event_pattern = var.cw_event_pattern
}
resource "aws_cloudwatch_event_target" "event_target" {
target_id = var.lambda_name
arn = var.... | figtools/figgy | Apache-2.0 | terraform/modules/triggers/cw_trigger/main.tf | aws | [
"aws_cloudwatch_event_rule",
"aws_cloudwatch_event_target",
"aws_lambda_permission"
] | 2ad01132eb3aa18efad46729f18f4dde |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a t2.micro Amazon EC2 instance in us-east-1 using the latest Ubuntu 20.04 LTS AMI from Canonical, with the instance name set via the instance_name variable, and configure Terraform to use the default AWS CLI profile for authentication. | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
profile = "default"
region = "us-east-1"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}
fi... | slawa-c/terraform-aws-core | Apache-2.0 | main.tf | aws | [
"aws_instance"
] | 7a26d0c34638ff619df1d74b0e9408b2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Kinesis Data Stream named using the provided variable, with a fixed shard count from a variable, 24-hour data retention, provisioned mode, and encryption using a KMS key with 7-day deletion window and automatic key rotation enabled; also output the stream’s name, ARN, and the KMS key’s ARN. | resource "aws_kinesis_stream" "kds" {
name = var.name
shard_count = var.kds_shard_count
retention_period = 24
encryption_type = "KMS"
kms_key_id = aws_kms_key.kds.id
tags = var.tags
shard_level_metrics = var.detailed_shard_level_metrics
stream_mode_details {
str... | WarnerMedia/prism-video | MIT | iac/modules/provisioned-kds/kds.tf | aws | [
"aws_kinesis_stream",
"aws_kms_key"
] | e7238172a9de47385f78e0ca79f56337 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Configure an S3 bucket to send event notifications to up to three types of destinations: Lambda functions, SQS queues, and SNS topics, with optional prefix/suffix filtering per destination; for SQS and SNS, automatically generate and attach the necessary resource-based policies to grant S3 permission to deliver message... | data "aws_partition" "this" {}
locals {
bucket_arn = coalesce(var.bucket_arn, "arn:${data.aws_partition.this.partition}:s3:::${var.bucket}")
# Convert from "arn:aws:sqs:eu-west-1:835367859851:bold-starling-0" into "https://sqs.eu-west-1.amazonaws.com/835367859851/bold-starling-0" if queue_id was not specified
#... | emir-deeeplabs/terraform-aws-s3-bucket | Apache-2.0 | modules/notification/main.tf | aws | [
"aws_lambda_permission",
"aws_s3_bucket_notification",
"aws_sns_topic_policy",
"aws_sqs_queue_policy"
] | b96afa95c41a819af9eca99e4abf608a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC peering connection between the DevOps VPC and the Apps VPC, automatically accept it, tag it with a name combining the project codegroup names, and add routes in both VPCs’ public route tables to allow traffic between their CIDR blocks. | resource "aws_vpc_peering_connection" "vpc_peering_connection_project_codegroup_apps_project_codegroup_devops" {
peer_vpc_id = data.terraform_remote_state.network_apps_codegroup_remote_state.outputs.vpc_id_project_codegroup_apps
vpc_id = aws_vpc.vpc_project_codegroup_devops.id
auto_accept = true
tags = {
... | DennisAJG/project-codegroup | Apache-2.0 | Infra/Terraform-Project/devops/NETWORK/peering.tf | aws | [
"aws_route",
"aws_vpc_peering_connection"
] | 3b75fd0c61501e1594107eb2cb1d8f6a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `example_1_role` that allows the AWS account `111222333444` to assume it via `sts:AssumeRole`, and also allows any Kubernetes service account in any namespace of the EKS cluster with OIDC provider ID `FOO` in `us-west-2` to assume it via `sts:AssumeRoleWithWebIdentity` as long as the audience i... | data "aws_iam_policy_document" "example_1_trust_policy" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::111222333444:root"] # SNYK-CC-TF-118 violation due to "arn:aws:iam::111222333444:root"
}
}
statement {
... | pbnj-dragon/snyk-demo | Unlicense | example_1.tf | aws | [
"aws_iam_role"
] | 80e980474a3abdc79be6a7240c12dfb7 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a reserved Cache Node for ElastiCache using the specified offering ID, with a fixed count of cache nodes, a defined identifier, and region; apply the provided tags and configure explicit timeouts for creation, update, and deletion operations. | resource "aws_elasticache_reserved_cache_node" "this" {
reserved_cache_nodes_offering_id = var.reserved_cache_nodes_offering_id
cache_node_count = var.cache_node_count
id = var.id
region = var.region
tags = var... | ebogdum/terraform-providers | MIT | aws/resources/elasticache_reserved_cache_node/main.tf | aws | [
"aws_elasticache_reserved_cache_node"
] | f80c054e855c11b26140763f27400f7c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a variable number of EC2 instances named with a configurable tag prefix and sequential numbers, each using a specified AMI, instance type, and encrypted 30 GiB gp3 root volume derived from a given snapshot, deployed across three Availability Zones in a round-robin fashion, with public IPs enabled, API termina... | resource "aws_instance" "ec2_bat" {
count = var.bat_count
ami = var.ec2_ami
key_name = var.key
instance_type = var.bat_type
associate_public_ip_address = true
credit_specification {
cpu_credits = "standard"
}
ebs_block_device {
device_name = "/dev/xvda"
volume_size = 30
volume_type = "gp... | hosinokoe/aws_tf_v3 | Apache-2.0 | modules/services/ec2/bat/bat_ip/ec2.tf | aws | [
"aws_instance",
"aws_security_group"
] | 8531cc07b4266be99aaf1fcc529b4c76 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named after the project and a random hex suffix, enable versioning, block all public access at the bucket level while allowing account-level public access controls to remain permissive, configure a bucket policy that restricts `s3:GetObject` access exclusively to a specified CloudFront distribution’... | #============================================================
# S3
#============================================================
# バケット名とタグの設定
resource "aws_s3_bucket" "frontend" {
# バケット名
bucket = "${var.project_name}-${local.lower_random_hex}"
# バケットの中にオブジェクトが入っていてもTerraformに削除を許可するかどうか(true:許可)
force_destro... | Jingasan/terraform_tutorials | MIT | 01_AWS/03_CloudFront_ACM_Route53/s3.tf | aws | [
"aws_s3_account_public_access_block",
"aws_s3_bucket",
"aws_s3_bucket_cors_configuration",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_versioning",
"null_resource"
] | 18f3765c712b8b706ef0dbeb3c5558b8 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudWatch log group for the Kratos service with a name derived from the app name and environment, prefixed by `/ecs/`, and set its log retention to the value of `var.log_retention_days`; similarly, create a separate CloudWatch log group for the Hydra service with an identical naming pattern and retention sett... | # CloudWatch Log Group for Kratos (single service: public + admin APIs)
resource "aws_cloudwatch_log_group" "kratos" {
name = "/ecs/${var.app_name}-${var.environment}-kratos"
retention_in_days = var.log_retention_days
tags = merge(
var.common_tags,
{
Name = "${var.app_name}-${var.envi... | keyvera/ory-infra | Apache-2.0 | modules/cloudwatch/main.tf | aws | [
"aws_cloudwatch_log_group"
] | 29063b30076392d7786c0d0c233ad147 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a t2.micro EC2 instance named nginx in the ap-southeast-1 region using the AMI ami-0d728fd4e52be968f, assign it the terraform SSH key, run the install_nginx.sh script on boot, and attach a security group named nginx-sg that permits inbound SSH (port 22) and HTTP (port 80) from any IP, allows all outbound traf... | provider "aws" {
profile = "vungocson998"
region = "ap-southeast-1"
}
resource "aws_instance" "nginx" {
ami = "ami-0d728fd4e52be968f"
instance_type = "t2.micro"
tags = {
"Name" = "nginx"
}
user_data = file("install_nginx.sh")
key_name = "terraform"
vpc_security_group_ids =... | bridgecrew-perf4/learn-terraform-10 | Apache-2.0 | basics/ec2-nginx-sg/ec2.tf | aws | [
"aws_instance",
"aws_security_group"
] | 2eaf50d127ff9efff64213069e715296 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `tdk-terraform-state.io` in the us-east-1 region with versioning enabled and default server-side encryption using AES256, and provision a DynamoDB table named `terraform-state` with on-demand billing, using a string attribute `LockID` as the primary key for state locking. | provider "aws" {
region = "us-east-1"
}
resource "aws_s3_bucket" "terraform_state" {
bucket = "tdk-terraform-state.io"
# Enable versioning so we can see the full revision history of our state files
versioning {
enabled = true
}
# Enable server-side encryption by default
server_side_encryption_configu... | tkeech1/aws_bd | MIT | s3_state/main.tf | aws | [
"aws_dynamodb_table",
"aws_s3_bucket"
] | 6c740ad5d0463d8911ea935fa482936e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two load balancer target groups named `<var.name>-1` and `<var.name>-2`, each configured to operate within the specified VPC, using the given target type, protocol, and port, with health checks enabled using the provided protocol, port, path, status code matcher, and timing parameters for interval, timeout, and ... | resource "aws_lb_target_group" "this" {
count = 2
name = "${var.name}-${count.index + 1}"
vpc_id = var.vpc_id
target_type = var.target_type
protocol = var.protocol
protocol_version = var.protocol_version
port = var.target_port
# https://registry... | andreswebs/aws-ecs-tf | Unlicense | modules/lb-target-bluegreen/main.tf | aws | [
"aws_lb_target_group"
] | 0bd0855d535378d398da00b88893e8ee |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SNS topic named using the `var.s3_event_name` variable with the display name “Cemed Request Notification” and restrict publishing access to a specific Lambda function via its ARN. Provision an IAM role named `iam_for_lambda` that allows Lambda to assume it, and attach an inline policy granting permissions to ... | resource "aws_sns_topic" "topic" {
name = var.s3_event_name
display_name = "Cemed Request Notification"
tags = var.tags
policy = jsonencode(
{
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = "lambda.amazonaw... | felipefrocha/terraform-module-lambda-queue | Apache-2.0 | main.tf | aws | [
"aws_iam_role",
"aws_lambda_alias",
"aws_lambda_event_source_mapping",
"aws_lambda_function",
"aws_lambda_permission",
"aws_sns_topic"
] | ad8d04e76278735cd684a738cece91ca |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Set up a VPC in us-east-1 with two public subnets (10.0.1.0/24 in us-east-1a and 10.0.2.0/24 in us-east-1b) and two private subnets (10.0.3.0/24 in us-east-1a and 10.0.4.0/24 in us-east-1b), an internet gateway, and routing tables to allow public internet access for public subnets while keeping private subnets isolated... | ##############################
# ECS Fargate Deployment with RDS and CloudFront
# This Terraform configuration sets up an ECS Fargate service running a Gogs Server,
# backed by a PostgreSQL RDS instance, and fronted by a CloudFront distribution for HTTPS access.
##############################
# PROVIDER
provider "aws" ... | m-asif-gameplay-programmer/gogs_ecs_deploy_terraform | MIT | terraform/ECSDeploy/main.tf | aws | [
"aws_cloudfront_distribution",
"aws_cloudwatch_log_group",
"aws_db_instance",
"aws_db_subnet_group",
"aws_ecs_cluster",
"aws_ecs_service",
"aws_ecs_task_definition",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_internet_gateway",
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group",
... | 6e23dcd00f38e950594bdcdcb2c5dc25 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM user named `<name>-user` with read-only access to a specific S3 bucket (GetObject and ListBucket actions), and an IAM role named `<name>-role` that EC2 instances can assume, attached to a policy granting PutObject and GetObject permissions on the same bucket’s objects, along with an instance profile named... | locals {
name = var.name
tags = var.tags
}
resource "aws_iam_user" "readonly" {
name = "${local.name}-user"
tags = local.tags
}
resource "aws_iam_policy" "readonly_s3" {
name = "${local.name}-s3-readonly"
policy = data.aws_iam_policy_document.readonly_s3.json
tags = local.tags
}
resource "aws_iam_u... | ogulcanaydogan/terraform-aws-platform | MIT | templates/iam-examples/main.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_iam_user",
"aws_iam_user_policy_attachment"
] | b972334e31e7bc6bfb02422bb4a7acc2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a public subnet in the specified VPC and availability zone with a CIDR block assigned, ensuring public IP addresses are automatically assigned to instances launched in it; allocate a dedicated Elastic IP for NAT use in that VPC; and deploy a NAT gateway in the public subnet using that Elastic IP to enable outbou... | resource "aws_subnet" "subnet" {
vpc_id = var.vpc_id
availability_zone = var.availability_zone
cidr_block = var.cidr_block
map_public_ip_on_launch = true
tags = merge(
var.tags,
{
Name = "${var.prefix}-subnet-public-${var.availability_zone}"
}
)
}
reso... | oriol366/terraform-aws-vpc-module | MIT | modules/public_subnet/main.tf | aws | [
"aws_eip",
"aws_nat_gateway",
"aws_subnet"
] | 10328e3e571a5461987ee8bf3671872a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an 8-gigabyte EBS volume in the same availability zone as an EC2 instance named os1, and tag it with the name HelloWorld. | resource "aws_ebs_volume" "example" {
availability_zone = aws_instance.os1.availability_zone
size = 8
tags = {
Name = "HelloWorld"
}
} | YashIndane/terraform-scripts | MIT | split-files/ebbs.tf | aws | [
"aws_ebs_volume"
] | 30b0cb1ea474309389adcb694425fdb0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an EC2 instance in the specified region using the given AMI and instance type, attach it to a dedicated primary network interface in the provided subnet with the configured private IP addresses, and initialize it with a combined cloud-init script that includes a shell script from a local file and a templated ... | // Copyright (c) 2020 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the LICENSE file.
provider "aws" {
region = var.region
}
resource "aws_network_interface" "intf" {
subnet_id = var.subnet_id
private_ips = var.private_ips
tags = {
Name = "... | aristanetworks/CloudEOS | Apache-2.0 | terraform/module/cloudeos/aws/host/host.tf | aws | [
"aws_instance",
"aws_network_interface"
] | a600d8a173b5908df15f1797d35ece11 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Network Monitor for each target in `var.targets`, naming each monitor after the target’s name and setting its aggregation period to 30 seconds unless overridden. For each probe defined in `local.probes`, create a corresponding probe linked to its specified monitor, destination, port, protocol, and source ARN, ... | resource "aws_networkmonitor_monitor" "this" {
for_each = { for i in var.targets : i.name => i }
#for_each = { for i in local.probes : i.name => i }
aggregation_period = try(each.value.aggregation_period, 30)
monitor_name = each.key
}
resource "aws_networkmonitor_probe" "this" {
for_each = { for i in ... | dvmrry/tf-module-aws-probe | BSD-2-Clause | main.tf | aws | [
"aws_networkmonitor_monitor",
"aws_networkmonitor_probe"
] | 9840d246f8662e771f566ace1e23d67a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS service named using the `service_name` variable, running in the cluster specified by `cluster_name`, with a task count defined by `service_task_count`, using a deployment strategy that allows up to 200% capacity during updates while ensuring at least 100% of tasks remain healthy, enabling automatic rollba... | resource "aws_ecs_service" "main" {
name = var.service_name
cluster = var.cluster_name
task_definition = aws_ecs_task_definition.main.arn
desired_count = var.service_task_count
deployment_maximum_percent = 200
deployment_minimum_healthy_percent = 100
deployment_circuit_breaker {
enable ... | thdblinux/mandalor-containers-ecs-service-module | MIT | service.tf | aws | [
"aws_ecs_service"
] | b0b92cff57259d66a3702ed4f3e1a96f |
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 prefix “WAF” followed by the valid web ACL name, assuming the role for the Kinesis Firehose service; attach a policy granting Firehose permission to write logs to a specific S3 bucket named by the `filmdrop_archive_bucket_name` variable, invoke a specific Lambda function in us-east-1, ... | # Define role to log WAF Requests - Role is specific to each Cloudfront WAF
resource "aws_iam_role" "waf_logging_firehose_role" {
name_prefix = "WAF${local.valid_web_acl_name}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
... | KayakinCoder/filmdrop-learn | Apache-2.0 | modules/cloudfront/waf_qp_bytematch/log_configuration/iam.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | b9597de7a772f31846a6e5bd29b6e972 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an EC2 instance in the specified region using the AMI mapped for that region, with a configurable instance type, a public IP, and attach it to the given subnet and security group. Use the provided key pair for SSH access, assign it the specified IAM instance profile, and run the rendered shell script as user ... | resource "aws_instance" "instance" {
ami = var.AMIS[var.aws_region]
instance_type = var.instance_type
associate_public_ip_address = "true"
vpc_security_group_ids = [aws_security_group.instance_sg.id]
subnet_id = var.subnet
key_name ... | afaryy/terraform-aws | MIT | TDL-06-EC2-Cloudwatch-S3/terraform-code-ec2-cw-s3object/ec2.tf | aws | [
"aws_instance"
] | 8103381eec7d7f744f36016db2e38b91 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Glue database named `database_<environment>` in the eu-west-1 region, along with an IAM role named `iam-role-<environment>` that Glue can assume, attach the AWSGlueServiceRole managed policy and a custom policy granting full S3 access to `ARBITRARY-BUCKET-NAME/*`, then configure three Glue crawlers: one n... | provider "aws" {
region = "eu-west-1"
}
terraform {
backend "s3" {}
}
data "aws_caller_identity" "current" {}
resource "aws_glue_catalog_database" "database" {
name = "database_${var.environment}"
}
resource "aws_iam_role" "iam_role" {
name = "iam-role-${var.environment}"
assume_role_policy = <<EOF
{
"... | mleuthold/terraform-with-terragrunt | MIT | infrastructure-modules/aws/cujo-athena-tables/main.tf | aws | [
"aws_glue_catalog_database",
"aws_glue_crawler",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 5fb6567ebad012beac63955d91385732 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy named `<cluster_name>-alb-controller-policy` that embeds the AWS Load Balancer Controller’s IAM policy document fetched from the official GitHub repository at version 2.7.2, and create an IAM role named `<cluster_name>-alb-controller-role` that allows the Kubernetes service account in the specified... | data "aws_caller_identity" "current" {}
data "http" "alb_controller_policy" {
url = "https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.7.2/docs/install/iam_policy.json"
}
resource "aws_iam_policy" "alb_controller" {
name = "${var.cluster_name}-alb-controller-policy"
descripti... | Bamidele0102/retail-store-sample-app | MIT-0 | innovatemart-project-bedrock/terraform/modules/alb-iam/main.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | c09310d99ddb2341bffdf7737a81d452 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy named after the environment with “-create-booking-policy” suffix that grants permission to insert items into the bookings DynamoDB table, and embed the policy document from the `dynamodb-policy.tpl` template file. | resource "aws_iam_policy" "create_booking_policy" {
name = "${var.environment}-create-booking-policy"
description = "This policy allows data insertion on booking dynamodb table"
policy = templatefile("${path.module}/templates/dynamodb-policy.tpl",{
action = "dynamodb:PutItem",
resource = "${aw... | andreciornavei/serverless | MIT | terraform/infra/bookings/iam-policy-create-booking.tf | aws | [
"aws_iam_policy"
] | c5596dc59ff2b903950c06b0928b8e67 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Elastic Beanstalk application named “flask” with a development environment called “dev-env” running a single-instance WebServer tier on Python 3.11 in Amazon Linux 2023, deployed from an S3 bucket named “flask.uneze” that stores two application versions: “flask-v1.zip” under the key “flask_v1/flask-v1.zip... | resource "aws_elastic_beanstalk_application" "flask" {
name = "flask"
description = "event-driven-app beanstalk deployment"
}
resource "aws_elastic_beanstalk_environment" "dev_env" {
name = "dev-env"
application = aws_elastic_beanstalk_application.flask.name
tier ... | network-charles/AWS-Dev-Associate | MIT | Lab 5/beanstalk_infrastructure/compute.tf | aws | [
"aws_elastic_beanstalk_application",
"aws_elastic_beanstalk_application_version",
"aws_elastic_beanstalk_configuration_template",
"aws_elastic_beanstalk_environment",
"aws_s3_bucket",
"aws_s3_object",
"aws_ssm_parameter",
"null_resource"
] | 89bbc845fa01104d4b9e636e1fd34cf4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudFront distribution that serves a static website hosted in a specific S3 bucket, using Origin Access Control to restrict direct public access to the bucket while allowing CloudFront to retrieve objects via signed requests with AWS Signature Version 4; configure the distribution to use the S3 bucket’s regio... |
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_origin_access_control
resource "aws_cloudfront_origin_access_control" "default" {
name = "OAC ${aws_s3_bucket.website_bucket.bucket}"
description = "Origin Access control for s... | ragerumal/terraform-beginner-bootcamp-2023 | MIT | modules/terrahouse_aws/resource-cdn.tf | aws | [
"aws_cloudfront_distribution",
"aws_cloudfront_origin_access_control",
"terraform_data"
] | 784be1aa1a9b7430471f68b9a8aeddb3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM user named “privesc11-PutGroupPolicy-user” with an access key, attach to it a policy named “privesc11-PutGroupPolicy” that grants permission to call iam:PutGroupPolicy on any resource, create an IAM role named “privesc11-PutGroupPolicy-role” that can be assumed by the specified AWS account ARN and also at... | resource "aws_iam_policy" "privesc11-PutGroupPolicy" {
name = "privesc11-PutGroupPolicy"
path = "/"
description = "Allows privesc via iam:PutGroupPolicy"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
policy = jsonencode({
Version = "201... | BishopFox/iam-vulnerable | MIT | modules/free-resources/privesc-paths/privesc11-PutGroupPolicy.tf | aws | [
"aws_iam_access_key",
"aws_iam_group",
"aws_iam_group_membership",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_iam_user",
"aws_iam_user_policy_attachment"
] | 3504db6971962a3fc3b5be42682a7b58 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Global Accelerator named after the deployment ID with IPv4 addressing, enabled with flow logs configured to write to a specified S3 bucket and prefix, attach it to all load balancers that require DDoS protection by creating TCP listeners for each unique port they expose and routing traffic to those load b... | locals {
global_accelerator_hosted_zone_id = var.use_fips_endpoint ? "Z018824593QZ67JH632G" : "Z2BJ6XQ5FK7U4H" # Fixed Hosted Zone ID for Global Accelerator
create_global_accelerator = length(local.lbs_with_ddos_protection) > 0
create_dns_records = local.create_global_accelerator && var.fqdn != ""
has_apps_p... | dominodatalab/terraform-aws-eks | Apache-2.0 | modules/load-balancers/ddos.tf | aws | [
"aws_globalaccelerator_accelerator",
"aws_globalaccelerator_endpoint_group",
"aws_globalaccelerator_listener",
"aws_route53_record"
] | c19a7ee19beecb7c19138f957e973bfd |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Enable strict security controls for the AWS account: enforce a strong password policy with complexity requirements and password reuse prevention; activate account-level Access Analyzer; ensure all new EBS volumes and snapshots are encrypted and cannot be made public; block public access to S3 buckets, VPC internet gate... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
# discovered data resources to make configuration easier
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
data "aws_guardduty_detector" "account" {}
data "aws_ebs_encryption_by_default" "current" {}
# Accoun... | fortunecookiezen/aws-tf-account-security | Apache-2.0 | main.tf | aws | [
"aws_accessanalyzer_analyzer",
"aws_ebs_encryption_by_default",
"aws_ebs_snapshot_block_public_access",
"aws_ec2_image_block_public_access",
"aws_guardduty_publishing_destination",
"aws_iam_account_password_policy",
"aws_kms_alias",
"aws_kms_key",
"aws_s3_account_public_access_block",
"aws_s3_buck... | 5116d559d3463c45aa0e63a59f5ade13 |
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 Kubernetes cluster with `-pod-role-dify` suffix that allows the `dify-api` service account in the `dify` namespace to assume it via EKS OIDC, with the role’s trust policy locked to that specific service account and audience, and attach a policy defined in the local `policies/dify-api.... | resource "aws_iam_role" "dify_api" {
name = "${var.k8s_cluster_name}-pod-role-dify"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRoleWithWebIdentity"
Principal = {
Federated = "arn:aws:iam::${data.aws_caller_identity.current.id... | trkd-knt/dify-on-eks | MIT | terraform/modules/k8s/dify/k8s_sa/main.tf | k8s | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"kubernetes_service_account"
] | 297e533c508f767ca0d472bc17c096ac |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Athena workgroup named according to the `athena_workgroup_name` variable, enforce its configuration settings, enable CloudWatch metrics publishing, and set the query result output location to an S3 bucket specified by the `athena_result_bucket_name` variable under the `athena-result/` prefix, applying common ... | ################################################################################
# Athena Workgroup
################################################################################
resource "aws_athena_workgroup" "this" {
name = var.athena_workgroup_name
configuration {
enforce_workgroup_configuration = true... | sunakan/sunady2020-athena | MIT | infra/terraform/modules/2-athena-workgroup/main.tf | aws | [
"aws_athena_workgroup"
] | 68ce414c51ad81df604b9461d65af9ec |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two CloudFront distributions, each backed by an S3 bucket: one for Team A in the dev environment and one for Team B in the prod environment; ensure each S3 bucket is private by blocking all public access and is accessed via an Origin Access Control using Sigv4 signing; configure both distributions with IPv6 enab... | # Demo Resources - CloudFront Distributions to test the policies
# S3 Bucket for Dev Environment (Team A)
resource "aws_s3_bucket" "dev_content" {
provider = aws.account_dev
bucket = "team-a-dev-content-${random_id.global_suffix.hex}"
force_destroy = true
tags = merge(var.team_a_tags, {
Enviro... | Worxfr/AFMDemoCloudfront | MIT | demo_resources.tf | aws | [
"aws_cloudfront_distribution",
"aws_cloudfront_origin_access_control",
"aws_s3_bucket",
"aws_s3_bucket_public_access_block"
] | 51483e282cf1b42ad84b03dae1fdfa53 |
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 project name, a random 8-character lowercase alphanumeric suffix, and force deletion enabled; enable versioning to retain artifact history; configure server-side encryption using AES256; and block all public access including ACLs, policies, and bucket restrictions. | # S3 Bucket for CodePipeline Artifacts
# Stores source code, build artifacts, and intermediate files during CI/CD process
resource "aws_s3_bucket" "artifacts" {
bucket = "${var.project_name}-artifacts-${random_string.bucket_suffix.result}"
force_destroy = true # Allow deletion even with objects (useful for d... | atkaridarshan04/aws-cloud-projects | MIT | ecs-cicd-pipeline/terraform/s3.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning",
"random_string"
] | 2377b00d9c5b63eee34f76b60c3feeee |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a globally unique S3 bucket named using the project name, environment, and a unique suffix to store Terraform state files, with versioning enabled, AES256 server-side encryption, all public access blocked, and automatic expiration of noncurrent versions after 90 days, plus a DynamoDB table named using the projec... | locals {
# Bucket name must be globally unique - use project name, environment, and unique suffix
bucket_name = "${var.project_name}-tf-state-${var.environment}-${var.unique_suffix}"
# DynamoDB table name for state locking
dynamodb_table_name = "${var.project_name}-tf-locks"
}
# S3 bucket for Terraform state ... | trungleviet-agilityio/terraform-training | MIT | practice/deploy/10_core/modules/s3/main.tf | aws | [
"aws_dynamodb_table",
"aws_s3_bucket",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning"
] | 28f590cadfeee0eb735c0e0fcabda907 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a load balancer named after the project with the specified internal or public type, using the three public subnets retrieved from SSM Parameter Store, with deletion protection and cross-zone load balancing disabled. Configure a default HTTP listener on port 80 that responds with a fixed 200 status, plain text co... | #
# Create Load Balancer
#
resource "aws_lb" "main" {
name = format("%s-lb", var.project_name)
internal = var.load_balancer_internal
load_balancer_type = var.load_balancer_type
subnets = [
data.aws_ssm_parameter.subnet_public_1a.value,
data.aws_ssm_parameter.subnet_public_1b.val... | eyaol/linuxtips-curso-containers-ecs-cluster | MIT | load_balancer.tf | aws | [
"aws_lb",
"aws_lb_listener"
] | df61eebe1c7b5e1036abf08a9047e0a9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role for Lambda execution named using the project and environment variables, attach the AWS managed Lambda basic execution policy, and attach a custom inline policy allowing CloudWatch Logs writes and CodePipeline read access. Also create an SNS topic policy that permits EventBridge to publish messages to... | # IAM roles for EventBridge, SNS, and Lambda
# Lambda execution role
resource "aws_iam_role" "lambda_role" {
name = "${var.project_name}-${var.environment}-lambda-role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"... | TanyaMushonga/aws-terraform-backend-cicd | MIT | modules/eventbridge/iam.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment",
"aws_sns_topic_policy"
] | 667905a1c6ee28aef9655a23db94b8e3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision two Amazon Linux EC2 instances of type t2.micro, each tagged with the name “web” and owner “Mahesh”. | # Create EC2 Instance
resource "aws_instance" "web" {
ami = "ami-047a51fa27710816e" # Amazon Linux
instance_type = "t2.micro"
count = 2
tags = {
"Name" = "web"
"Owner" = "Mahesh" #"Name" = "web-${count.index}"
}
} | mahesh430/devops-notes | Apache-2.0 | terraform-hands-on/04-Terraform-Resources/04-03-Meta-Argument-count/terraform-manifests/c2-ec2-instance.tf | aws | [
"aws_instance"
] | 8797773161bb22f2f544962af11dfcdf |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Gateway-type VPC endpoint for DynamoDB in the us-east-1 region, attach it to the specified VPC, and associate it with the given route table. | resource "aws_vpc_endpoint" "dynamo_vpc_endpoint" {
vpc_id = var.vpc_id
service_name = "com.amazonaws.us-east-1.dynamodb"
vpc_endpoint_type = "Gateway"
route_table_ids = [var.route_table]
} | jbarmasch/itba-cloud | MIT | terraform/modules/vpc_endpoint/main.tf | aws | [
"aws_vpc_endpoint"
] | ed52b2bc348eef2f643eb9de5ff1ca24 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket policy that enforces server-side encryption using AWS KMS for all object uploads and blocks any requests that do not use secure transport (HTTPS), but only when encryption is explicitly enabled via the `var.encryption` variable. | resource "aws_s3_bucket_policy" "main" {
count = (var.encryption == true) ? 1 : 0
bucket = aws_s3_bucket.main.id
policy = <<POLICY
{
"Version": "2012-10-17",
"Id": "SSEAndSSLPolicy",
"Statement": [
{
"Sid": "DenyUnEncryptedObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Ac... | magicorntech/terraform-aws-s3 | MIT | policy.tf | aws | [
"aws_s3_bucket_policy"
] | 51516d566224a472b28c2fe61fed1d72 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision seven types of EC2 instances—REST Proxy, Kafka Connect, ksqlDB, Control Center, Schema Registry, brokers, and ZooKeeper—each deployed in the default subnet of the specified VPC, using the same AMI, instance type, and key pair, with public IP addresses assigned and source/destination checking disabled, and nam... | provider "aws" {
region = "${var.aws_region}"
}
resource "aws_instance" "rest" {
count = "${var.instance_count["rest"]}"
ami = "${var.aws_ami}"
instance_type = "${var.aws_instance_type}"
key_name = "${var.key_name}"
vpc_security_group_ids = ["${aws_security_group.kafka_sg.id}"]
subnet_id ... | codecheq/kafka-cluster | MIT | terraform/instances.tf | aws | [
"aws_instance"
] | 9011614af7d00d90dadebfb0feb92fb3 |
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 “preferealty-sql” using version 16.3 of the engine, sized with 10 GB of storage and a db.t3.micro instance class, deployed in a private subnet within the current workspace’s Parameter Store path, with credentials and database name fetched securely from AWS Systems Manager Par... | locals {
base_parameter_path = "/preferealty/${terraform.workspace}"
}
# Fetch the db_name (stored as SecureString) from AWS Parameter Store
data "aws_ssm_parameter" "preferealty-psql-rds_db_name" {
name = "${local.base_parameter_path}/RDS_DB_NAME"
with_decryption = true # Decrypt the value securely
}... | htranassoc/preferealty-rails | MIT | terraform/setup/psql/rds.tf | aws | [
"aws_db_instance"
] | dcf0dd4dcd5f27be4c851e35cf241fce |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Associate additional IPv4 CIDR blocks with the main VPC, then create additional private subnets in each of the three availability zones (az1, az2, az3) using either provided CIDR blocks or dynamically allocated /29 subnets from the additional CIDR blocks, and similarly create additional public subnets in the same zones... | resource "aws_vpc_ipv4_cidr_block_association" "additional_cidr" {
for_each = toset(var.vpc_additional_cidr)
vpc_id = aws_vpc.main.id
cidr_block = each.value
}
# Additional Private Subnets #
resource "aws_subnet" "additional_sn_private_a" {
count = local.additional_sn_private_a
vpc_id ... | zoitech/terraform-aws-network | MIT | cidr.tf | aws | [
"aws_route_table_association",
"aws_subnet",
"aws_vpc_ipv4_cidr_block_association"
] | 7617b5f1854a84bbf26934d70310970c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `s3ich4n-ex3-file-layout-bucket` in `ap-northeast-2` to store Terraform state, and configure a DynamoDB table named `terraform-locks-week3-files` for state locking. Retrieve the VPC ID and RDS connection details (address and port) from an existing Terraform state stored at `stage/data-stores/m... | terraform {
backend "s3" {
bucket = "s3ich4n-ex3-file-layout-bucket"
key = "stage/services/webserver-cluster/terraform.tfstate"
region = "ap-northeast-2"
dynamodb_table = "terraform-locks-week3-files"
}
}
provider "aws" {
region = "ap-northeast-2"
}
##### terraform_rem... | s3ich4n/terraform-study-101 | MIT | chapter03/example03-file-layout/stage/services/webserver-cluster/main.tf | aws | [
"aws_autoscaling_group",
"aws_internet_gateway",
"aws_launch_configuration",
"aws_lb",
"aws_lb_listener",
"aws_lb_listener_rule",
"aws_lb_target_group",
"aws_route",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_security_group_rule",
"aws_subnet"
] | 057b1f8c7333396b18b56b47c50df9b5 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an OpenID Connect provider for AWS IAM using the URL, client IDs, thumbprints, and tags provided via variables. | resource "aws_iam_openid_connect_provider" "this" {
url = var.url
client_id_list = var.client_id_list
thumbprint_list = var.thumbprint_list
tags = var.tags
} | ebogdum/terraform-providers | MIT | aws/resources/iam_openid_connect_provider/main.tf | aws | [
"aws_iam_openid_connect_provider"
] | 0177ae837d92b7709039cd122c0edcb0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Cognito user pool with a randomly generated name, configure it to allow only admin-initiated account recovery, define a resource server with a scope named “localstack” granting read access to localstack, and set up a user pool client that uses client credentials OAuth flow, supports user password and SRP authe... | data "aws_region" "current" {}
data "aws_caller_identity" "current" {}
resource "random_pet" "random" {
length = 2
separator = "-"
}
resource "aws_cognito_user_pool" "pool" {
name = random_pet.random.id
account_recovery_setting {
recovery_mechanism {
name = "admin_only"
priority = 1
... | localstack-samples/localstack-terraform-samples | Apache-2.0 | sample-archive/apigatewayv2-jwt-client-credentials-http-proxy/main.tf | aws | [
"aws_apigatewayv2_api",
"aws_apigatewayv2_authorizer",
"aws_apigatewayv2_integration",
"aws_apigatewayv2_route",
"aws_apigatewayv2_stage",
"aws_cognito_resource_server",
"aws_cognito_user_pool",
"aws_cognito_user_pool_client",
"aws_cognito_user_pool_domain",
"random_pet"
] | 44aa52573a686b904c8c91acf6f21fcd |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a default security group for the database in the specified VPC, allow inbound TCP traffic on the configured port from the provided CIDR blocks if any are given, allow inbound TCP traffic on the same port from the listed security groups, and permit all outbound traffic to any destination. | resource "aws_security_group" "this" {
description = "Default security group of the database"
vpc_id = var.vpc_id
}
resource "aws_security_group_rule" "inbound_traffic_cidr" {
count = length(var.cidr_blocks) > 0 ? 1 : 0
description = "inbound traffic database"
security_group_id = aws_security_gro... | openixit-solutions/terraform-aws-rds | MIT | security_group.tf | aws | [
"aws_security_group",
"aws_security_group_rule"
] | 07714dd72e21d9e3f624a851ed6730a3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a t2.nano EC2 instance in us-west-1 using the most recent private Ubuntu 18-based AMI named unifi-controller-ubuntu18* owned by account 874011138780, and tag it with builder=terraform. | provider "aws" {
region = "us-west-1"
}
data "aws_ami" "unifi-controller" {
most_recent = true
# If we change the AWS Account in which test are run, update this value.
owners = ["874011138780"]
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "is-public"
val... | patkaehuaea/terraform | Apache-2.0 | us-west-1/main.tf | aws | [
"aws_instance"
] | f8c157ec2e178704be9b6eca8817597e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.