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 autoscaling group named "asg_name" with a launch template that uses a Free Tier-eligible EC2 instance type, the latest Ubuntu 22.04 x86_64 AMI from Canonical, an IAM instance profile specified by a variable, a 20 GiB EBS volume attached at `/dev/sdf`, public IP assignment enabled, and security groups provided... | #######################################################
###### DATA SOURCES
#######################################################
# Validate instance type for Free Tier eligibility
data "aws_ec2_instance_type" "example" {
instance_type = var.instance_type
lifecycle {
postcondition {
condition = se... | ooluwgb/HashiCorp-Terraform-Professional-Prep | MIT | Part_3_Modules_and_Workflows/examples/section_6/00_modules/modules/compute/compute.tf | aws | [
"aws_autoscaling_group",
"aws_launch_template"
] | c9ee555538af006cace4dfc08a223641 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `terrahouse_website` tagged with the user’s UUID, configure it to serve a static website using `index.html` as the index document and `error.html` as the custom error page, upload `index.html`, `error.html`, and all files from the `assets/` subdirectory to the bucket with content-type headers ... |
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket
resource "aws_s3_bucket" "terrahouse_website" {
# bucket = var.bucket_name
# Bucket naming Rules
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
tags = {
UserUuid = var.user_uuid
}
... | agoetee/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"
] | 58a6289d96fc14ff08e2d855673b7abb |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a t3.micro Ubuntu instance in the first public subnet of the VPC, using the specified AMI, key pair, and IAM instance profile, tag it with the environment name suffixed by “-bastion” along with environment, product, and configuration labels, deploy an NGINX passthrough configuration file to /etc/nginx/passthr... | # #############################################################################
# Bastion Host
# SSH tunnel
# NGINX upstream proxy
# #############################################################################
resource "aws_instance" "bastion" {
ami = data.aws_ami.ubuntu.id
instance_type ... | mawinkler/playground-one | MIT | awsone/9-deep-security/bastion/ec2.tf | aws | [
"aws_instance"
] | ae7d25bc0f1d3fa1ac1b25f7e0b2a1f3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `karpenter-controller` that allows the Karpenter service account in the `karpenter` namespace of the unpaid developers’ Singapore EKS cluster to assume it via OIDC federation, attach a policy named `KarpenterController` defined in a local JSON file to that role, and create an instance profile n... | data "aws_iam_policy_document" "unpaid_developers_karpenter_controller_assume_role_policy" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "StringEquals"
variable = "${replace(var.unpaid_developers_singapore_eks_oidc_url, "https://", "")}:sub... | The-Unpaid-Developers/manifest | MIT | terraform/modules/kubernetes/karpenter/controller_role.tf | k8s | [
"aws_iam_instance_profile",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 5341227736948be50af12a763d2728cf |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudFormation stack named “cross-account-ds-data-source” that provisions an Athena data catalog using the Hive metastore type, passing in the local catalog name and a Lambda ARN as parameters to configure the metadata function for cross-account data access. | resource "aws_cloudformation_stack" "this" {
name = "cross-account-ds-data-source"
parameters = {
CatalogName = var.local_catalog_name
LambdaARN = var.cross_account_lambda_arn
}
template_body = <<STACK
{
"Parameters" : {
"CatalogName" : {
"Type" : "String"
},
"LambdaARN" : {
... | mmatecki/tf-cross-account-athena-query | Apache-2.0 | terraform/modules/athena/main.tf | aws | [
"aws_cloudformation_stack"
] | 487539e7bb8f7f7a7b16e909a3ae944a |
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 ECS cluster and service that allows ECS tasks to assume it, and attach a policy granting permissions to register and deregister targets with load balancers, describe EC2 resources and authorize security group ingress, pull container images from ECR, write logs to CloudWatch Logs, and ... | # =========================================
# AWS IAM ROLES E POLICIES
# =========================================
# Recursos IAM necessários para execução das tasks ECS
# Role IAM para execução das tasks ECS
resource "aws_iam_role" "service_execution_role" {
# Nome da role baseado no cluster e serviço
name = form... | JoshuelNobre/ecs-service-module | MIT | iam.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy"
] | 5746d73f09539823b5bfb0c207fe4cd4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with the name provided via the `s3_bucket_name` variable, set its access control to private, and tag it with Name equal to "Team" and Environment equal to "Terraform". | resource "aws_s3_bucket" "iam_demo_bucket_name" {
bucket = var.s3_bucket_name //s3 bucket name
acl = "private"
tags = {
Name = "Team"
Environment = "Terraform"
}
} | tinkusaini13/terraform-learn | Apache-2.0 | tf/aws/iam-ec2/iam-s3-ec2/s3.tf | aws | [
"aws_s3_bucket"
] | b8393819e91eb33c721c3151b772c7e6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSH key pair named with the variable `name` suffixed by `-ssm-key` and store its public key in AWS as an EC2 key pair, while also saving the public and private keys locally as `id_rsa.pub` and `id_rsa` respectively. | resource "aws_key_pair" "ssm_key" {
key_name = "${var.name}-ssm-key"
public_key = tls_private_key.ssh.public_key_openssh
}
resource "local_file" "public_ssh" {
content = tls_private_key.ssh.public_key_openssh
filename = "id_rsa.pub"
}
resource "local_file" "private_ssh" {
content = tls_private_key.ssh.p... | JamesWoolfenden/terraform-aws-ssm-bastion | Apache-2.0 | aws_key_pair.ssm_key.tf | aws | [
"aws_key_pair",
"local_file"
] | 453931d0eebcd328ba7dea5963da78b0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Aurora MySQL cluster named with the environment and system prefix, using a private subnet group spanning the specified availability zones, secured by a security group that allows inbound MySQL traffic only from designated source security groups and permits all outbound traffic, with the master password stored... | ################################################################################
# RDS Cluster (Aurora)
################################################################################
resource "aws_rds_cluster" "this" {
cluster_identifier = "${var.env}-${var.system}-rds-cluster"
availability_zones ... | tusmasoma/terraform-aws-ecs-fargate | MIT | modules/rds/cluster.tf | aws | [
"aws_db_subnet_group",
"aws_rds_cluster",
"aws_rds_cluster_parameter_group",
"aws_security_group",
"aws_security_group_rule",
"aws_ssm_parameter",
"aws_vpc_security_group_egress_rule",
"random_password"
] | 0a674e4834275ba9cbc720a784331d14 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an HTTP redirect rule on a load balancer listener that forwards requests matching a specific host header to a new host, port, and path using a 301 permanent redirect, with the rule assigned a fixed priority. | provider "aws" {
region = var.region
}
resource "aws_lb_listener_rule" "redirect" {
listener_arn = var.listener
priority = var.priority
action {
type = "redirect"
redirect {
port = var.dstPort
protocol = var.dstProto
host = var.dstHost
path = v... | virsas/terraform_alb_rule_redirect | MIT | main.tf | aws | [
"aws_lb_listener_rule"
] | 4959895a254dfbb19c29297f980e0257 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an external Network Load Balancer named with the ingress_lb_group_name variable suffixed by "-external", deployed across the first two filtered subnets, with deletion protection disabled, and attach a security group named with the same base name plus "-external-sg" that allows inbound HTTPS (port 443) traffic fr... | # external NLB
resource "aws_lb" "external_nlb" {
name = "${var.ingress_lb_group_name}-external"
internal = false
load_balancer_type = "network"
enable_deletion_protection = false
subnet_mapping {
subnet_id = data.aws_subnets.filtered_subnets.ids[0]
}
... | UKHomeOffice/core-cloud-ingress-terraform | MIT | modules/ingress/nlb-isolated/external.tf | aws | [
"aws_lb",
"aws_security_group"
] | 7cd180d673f6fda79f9f2f9f30f19e5b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EKS cluster with two dedicated IAM roles: one for the cluster itself (with the managed policies AmazonEKSClusterPolicy and AmazonEKSServicePolicy) and one for the node group (with AmazonEKSWorkerNodePolicy, AmazonEKS_CNI_Policy, and AmazonEC2ContainerRegistryReadOnly), plus an IAM policy and role for the AWS ... | # EKS Cluster IAM Role
resource "aws_iam_role" "eks_cluster_role" {
name = "${var.cluster_name}-eks-cluster-role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = "eks.amazonaws.com"
}
Action = ... | chiangyaw/aws-eks-cluster | MIT | iam.tf | k8s | [
"aws_iam_openid_connect_provider",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | f88ef8fd90160159fe005d3c578794a3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a remote Terraform workspace in the FamestadDevIV organization with a dev- prefix, configure the AWS provider using the ivaf-sandbox profile in us-west-2, and provision an S3 bucket named super-secret-stuff-no-hackers-allowed tagged as “Super Secret Stuff” in the Dev environment. | terraform {
backend "remote" {
hostname = app.terraform.io
organization = "FamestadDevIV"
workspaces {
prefix = "dev-"
}
}
}
provider "aws" {
profile = "ivaf-sandbox"
region = "us-west-2"
}
variable "bucket_name" {
type = string
default = "super-secret-stuff-no-hackers-allowed"
}
re... | jfamestad/tf-tinker | MIT | main.tf | aws | [
"aws_s3_bucket"
] | d125c0b93f7607c95770ccc36abcf8f7 |
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 a user-provided UUID tag, configure it to serve a static website with `index.html` as the index document and `error.html` as the error page, upload the local `index.html` and all `.jpg`, `.png`, and `.gif` files from a specified assets directory (placing assets under an `assets/` prefix),... | # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket
resource "aws_s3_bucket" "website_bucket" {
# Bucket Naming Rules
#https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html?icmpid=docs_amazons3_console
# bucket = var.bucket_name
# Assign a random bucket... | EOyebamiji/terraform-beginner-bootcamp-2023 | MIT | modules/terrahouse_aws/resource-storage.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_policy",
"aws_s3_bucket_website_configuration",
"aws_s3_object",
"terraform_data"
] | 21c6afdfdd27b3b2df5962861418477d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSM parameter store hierarchy under a configurable prefix to register an OSDU instance, storing its name, IAM role prefix, tenant group name, Kubernetes namespace prefix, Cognito user pool name, and ElastiCache cluster name as separate string parameters; also expose key configuration values—including the SSM ... | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the “License”).
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | schundu007/infra-aws-provisioning | Apache-2.0 | deployment/osdu/instance/aws-base/instance-registration/main.tf | aws | [
"aws_ssm_parameter"
] | 31ce4438f6d834ea89a7ff4738001c7f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “banking-vpc” with a 10.0.0.0/16 CIDR block, enabling DNS hostnames and support; attach an internet gateway named “banking-igw” to it; provision two public subnets named “banking-public-subnet-1” and “banking-public-subnet-2” in the first two available availability zones, each with a /24 CIDR block a... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = var.aws_region
}
# VPC
resource "aws_vpc" "banking_vpc" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "banking-vpc"
}
}... | omokarogabriel/banking-system | MIT | infrastructure/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | bc3296f6ce3c5e4e265f705277c11e9a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a FortiGateVM active instance in a specific availability zone with four network interfaces: eth0 in the public subnet with two private IPs (one static, one floating), eth1 in the private subnet with two private IPs (one static, one floating) and source/destination checking disabled, eth2 in the sync subnet wi... | // FGTVM active instance
resource "aws_network_interface" "eth0" {
description = "active-port1"
subnet_id = var.publiccidrid
private_ip_list_enabled = true
private_ip_list = [var.activeport1, var.activeport1float]
}
resource "aws_network_interface" "eth1" {
description ... | jenkins611/FortiOS | MIT | aws/7.4/ha-single-az-existing/instance-active.tf | aws | [
"aws_instance",
"aws_network_interface",
"aws_network_interface_sg_attachment"
] | 64b2e593b214b2fbe8b770930371310e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a KMS key named “cross-region-snapshots” with a seven-day deletion window, attach an alias “alias/cross-region-snapshots” to it, and configure its key policy to grant the current AWS account full KMS permissions and allow all principals to use the key for any KMS action. | data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
locals {
aws_account_id = data.aws_caller_identity.current.account_id
aws_region = data.aws_region.current.name
aws_account_principal = "arn:aws:iam::${local.aws_account_id}:root"
}
resource "aws_kms_key" "default" {
desc... | epomatti/aws-kms-crossregion-snapshots | MIT | modules/kms/main.tf | aws | [
"aws_kms_alias",
"aws_kms_key",
"aws_kms_key_policy"
] | 93c784b410e6ad9c57d7091418f9bd70 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “stydygroup_vpc” in the eu-west-1 region with a /16 CIDR block and default tenancy, attach two public subnets—one in eu-west-1a with CIDR 10.0.0.0/20 and another in eu-west-1b with CIDR 10.0.16.0/20—deploy an internet gateway connected to the VPC, and configure a route table that directs all traffic ... | resource "aws_vpc" "stydygroup_vpc" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
provider = aws.accountA
tags = {
Name = "stydygroup_vpc"
createdBy = "Terraform"
env = "dev"
}
}
resource "aws_subnet" "stydygroup_public_subnet" {
vpc_id = aws_vpc.stydygroup_vpc.id
cidr... | miroslav93/saa-study-group | MIT | vpc.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_subnet",
"aws_vpc"
] | d5dca787895e22c249a887f5d22ee432 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Enable auto-scaling for broker storage in the MSK cluster, setting the minimum capacity to one broker and the maximum to the value specified in the configuration, using a role ARN provided in the configuration or leaving it null if none is given, and configure a target tracking policy that scales broker storage volume ... | ################################################################################
# Storage Autoscaling
################################################################################
resource "aws_appautoscaling_target" "this" {
count = var.storage_autoscaling_config.enabled ? 1 : 0
max_capacity = var.stor... | sourcefuse/terraform-aws-arc-msk | Apache-2.0 | modules/standard/autoscaling.tf | aws | [
"aws_appautoscaling_policy",
"aws_appautoscaling_target"
] | 848d4c1defb880eee04c9bde8f1a5f14 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudWatch log group named with the prefix “hello_world-” that retains logs for one day, define an ECS task using the “hello-world” Docker image with 128 MB memory and no CPU, configured to send logs to that log group in eu-west-1 with the stream prefix “ec2”, and deploy exactly one instance of that task as an... | resource "aws_cloudwatch_log_group" "this" {
name_prefix = "hello_world-"
retention_in_days = 1
}
resource "aws_ecs_task_definition" "this" {
family = "hello_world"
container_definitions = <<EOF
[
{
"name": "hello_world",
"image": "hello-world",
"cpu": 0,
"memory": 128,
"logConfigu... | Sk1810/terraform1 | Apache-2.0 | examples/complete/service-hello-world/main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_ecs_service",
"aws_ecs_task_definition"
] | dafc14f78c02c597aa33b6f23eb3bd0a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create multiple security groups based on a local list, each with a custom name, description, and VPC ID; configure each to allow specific inbound traffic defined by port ranges, protocols, and CIDR blocks, while permitting all outbound traffic to any destination; tag each security group with its name, the current envir... | # #############################################################################
# Security Group
# #############################################################################
resource "aws_security_group" "sg" {
for_each = local.security_groups
name = each.value.name
description = each.value.descripti... | mawinkler/playground-one | MIT | awsone/9-deep-security/ec2/sg.tf | aws | [
"aws_security_group"
] | 0105b05ed68d4659650d2820a21f06a8 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with a configurable CIDR block and optional secondary CIDR blocks, enabling DNS hostnames and support, and optionally assigning an IPv6 CIDR block; provision public and private subnets across specified availability zones, with public subnets optionally mapping public IPs on launch and assigning IPv6 addres... | locals {
max_subnet_length = max(
length(var.private_subnets),
)
nat_gateway_count = var.single_nat_gateway ? 1 : var.one_nat_gateway_per_az ? length(var.azs) : local.max_subnet_length
# Use `local.vpc_id` to give a hint to Terraform that subnets should be deleted before secondary CIDR blocks can be free!
... | kloia/platform-modules | MIT | modules/aws-vpc/main.tf | aws | [
"aws_default_network_acl",
"aws_default_route_table",
"aws_default_security_group",
"aws_egress_only_internet_gateway",
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_network_acl",
"aws_network_acl_rule",
"aws_route",
"aws_route_table",
"aws_route_table_association",
"aws_subnet"... | e1cabb830105907fe5ea6a56b6336fd1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM user named via the `cli_admin_username` variable, attach to it a policy granting full S3 permissions—including bucket and object management, versioning, encryption, and public access controls—necessary for Terraform state management, and also attach a policy granting full DynamoDB permissions—including ta... | # IAM configuration for CLI admin user
# Variable to control whether to create these resources
variable "cli_admin_username" {
description = "Username of the CLI admin user that needs S3 and DynamoDB permissions"
type = string
}
# Get the CLI admin user data
data "aws_iam_user" "cli_admin" {
user_name = ... | MeelisM/aws-code-keeper | MIT | terraform/bootstrap/iam.tf | aws | [
"aws_iam_policy",
"aws_iam_user_policy_attachment"
] | 7250b697c6ea7920b6cf182a27cbe9aa |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a regional API Gateway named `<project_name>-<environment>-api` with a single `/events` POST endpoint that requires an API key, forwards requests to an SQS queue using IAM role credentials, returns structured JSON responses for 200, 400, and 500 status codes, deploys to a stage matching the environment, enables ... | # modules/api_gateway/main.tf
# Data source to get current region
data "aws_region" "current" {}
# REST API Gateway
resource "aws_api_gateway_rest_api" "obsidian_sync_api" {
name = "${var.project_name}-${var.environment}-api"
description = "API Gateway for Obsidian Sync file change events"
endpoint_conf... | aarangop/note-rags-infrastructure | MIT | modules/api_gateway/main.tf | aws | [
"aws_api_gateway_account",
"aws_api_gateway_api_key",
"aws_api_gateway_deployment",
"aws_api_gateway_integration",
"aws_api_gateway_integration_response",
"aws_api_gateway_method",
"aws_api_gateway_method_response",
"aws_api_gateway_method_settings",
"aws_api_gateway_resource",
"aws_api_gateway_re... | 44d3a0e02f8eb38d3cbe77c30e40f9c1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Network Firewall with a single stateful rule group named “basic-allow-rules” containing no rules, a firewall policy named “policy” that forwards stateless traffic to SFE, alerts on established stateful connections, uses strict rule ordering, and defines HOME_NET as the VPC CIDR; deploy the firewall in the main... | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
# Basic Rule Group
resource "aws_networkfirewall_rule_group" "basic_rules" {
capacity = 100
name = "${var.project_name}-basic-allow-rules"
type = "STATEFUL"
rule_group {
rules_source {
rules... | aws-samples/aws-network-firewall-terraform | MIT-0 | multi_endpoint/firewall.tf | aws | [
"aws_networkfirewall_firewall",
"aws_networkfirewall_firewall_policy",
"aws_networkfirewall_rule_group",
"aws_networkfirewall_vpc_endpoint_association"
] | 808f833a6fe3bbbd23c2a35f8eaf508d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a single EC2 instance named Bastion_Server using the AMI ID and instance type passed as variables, place it in the specified subnet, attach it to the given security group, and assign it the key pair named Mafia. | #bastion_server_instance
resource "aws_instance" "bastion_server" {
ami = var.ami_id
instance_type = var.instance_type
subnet_id = var.subnet_id
vpc_security_group_ids = [var.vpc_sg_id]
key_name = "Mafia"
tags = {
Name = "Bastion_Server"
}
} | ShubhamSarkar516/3tier-architecture-using-terraform_ansible | MIT | modules/bastion/main.tf | aws | [
"aws_instance"
] | 11126554169d2a1d6056f9d580f2555e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Auto Scaling group named “ecs-instance” with exactly one instance, using the latest version of the ECS launch template, deployed across two specific public subnets (public and public_b), and ensure new instances are created before old ones are destroyed during updates. |
resource "aws_autoscaling_group" "ecs_asg" {
desired_capacity = 1
max_size = 1
min_size = 1
# Public b is only used in gpt-3 and example-1
vpc_zone_identifier = [aws_subnet.public.id, aws_subnet.public_b.id]
launch_template {
id = aws_launch_template.ecs_lt.id
versio... | benrhine/spring-boot-with-aws-ecs-and-terraform | MIT | terraform/example-1/autoscaling-group.tf | aws | [
"aws_autoscaling_group"
] | 95e77cf0f59f131342abf65219749b7c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a cross-account IAM role named with the project and environment that allows the DevOps account to assume it using a specific external ID, and attach a policy granting full permissions across EC2, Elastic Load Balancing, Auto Scaling, RDS, Secrets Manager, ACM, Route 53, CloudWatch, CloudWatch Logs, and IAM PassR... | # Cross-Account IAM Roles and Policies
# Cross-account deployment role for DevOps to access Production
resource "aws_iam_role" "cross_account_deployment" {
count = var.account_type == "production" ? 1 : 0
name = "${var.project_name}-${var.environment}-cross-account-deployment"
assume_role_policy = jsonencode({... | elngovind/terraform-project | MIT | modules/cross-account/main.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy"
] | 6dc633c1e65e3e73e43fcfca4dbf7cb8 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSH key pair using a 4096-bit RSA key, register the public key in AWS under the name “ec2-dvwa-key”, and save the private key as a secure, read-only PEM file named “ec2-dvwa-key.pem” in the module’s directory; set up a security group named “waf-alb-sg” in the main VPC to allow unrestricted inbound HTTP (port ... | #####################
# 7. EC2 Key Pair 및 PEM 파일 생성
#####################
resource "tls_private_key" "ssh_key" {
algorithm = "RSA" # RSA 알고리즘을 사용한 키 생성
rsa_bits = 4096 # RSA 키 길이를 4096비트로 설정
}
resource "aws_key_pair" "gene... | whs-dontdothat-aws/aws_terraform | MIT | advanced-detection-and-response-scenarios/guardduty-malware-protection/security_ec2.tf | aws | [
"aws_instance",
"aws_key_pair",
"aws_security_group",
"local_file",
"tls_private_key"
] | 0d4e78a86cf9c588429fdd4b34dd8b9b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `demo-ecs-instance-role` that EC2 instances can assume to run ECS tasks, attach the AWS-managed `AmazonEC2ContainerServiceforEC2Role` policy to it, and create an instance profile named `demo-ecs-instance-profile` wrapping that role. Also create a separate IAM role named `demo-ecs-task-execution... | resource "aws_iam_role" "demo_ecs_instance_role" {
name = "demo-ecs-instance-role"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Action = "sts:AssumeRole",
Principal = {
Service = "ec2.amazonaws.com"
},
Effect = "Allow"
}]
})
}
resource "aws_... | hzabun/personal-aws-devops-playground | MIT | ecs/terraform/iam.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 85d1a073c9062732675778739bfbfd01 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “k8s” with CIDR 192.168.0.0/16, enable DNS hostnames and support, attach an internet gateway named “k8s”, configure a route table named “k8s” with a default route to the internet gateway, and provision two public subnets named “my_subnet_1” and “my_subnet_2” in eu-west-2a and eu-west-2b respectively,... | resource "aws_vpc" "k8s" {
cidr_block = "192.168.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "k8s"
}
}
resource "aws_internet_gateway" "k8s" {
vpc_id = aws_vpc.k8s.id
tags = {
Name = "k8s"
}
}
resource "aws_route_table" "k8s" {
vpc_id = aws... | network-charles/CKS | MIT | Lab 21/networking.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 1903b3bdea93ab37fef212fa5765de85 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a DynamoDB table named `<stack-name>-lock-stack-tfstate-s3-backends` for each stack defined in `local.stacks_info`, with on-demand billing, a single string attribute `LockID` as the primary key, and tags that include the stack identifier. | resource "aws_dynamodb_table" "stack_tfstate_backends_lock" {
for_each = local.stacks_info
name = "${each.key}-lock-stack-tfstate-s3-backends"
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
tags = merge(local.tags, {
StackID = each.... | schollii/terraform-aws-sol | Apache-2.0 | mono-bucket-backends/state-lock.tf | aws | [
"aws_dynamodb_table"
] | ff026b354265e379600f7d62315e9f5e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an HTTP API named “Terraform Registry” with a “live” stage that auto-deploys, exposing a public discovery endpoint at `/.well-known/terraform.json` that serves a JSON file from an S3 bucket with public-read access and reduced redundancy storage, a webhook POST endpoint at `/webhook` that invokes a specific Lambd... | locals {
endpoint_root = var.custom_domain_name == null ? format("%s/%s", aws_apigatewayv2_api.registry.api_endpoint, aws_apigatewayv2_stage.registry.name) : format("https://%s", var.custom_domain_name)
}
# Discovery
resource "aws_s3_bucket_object" "discovery_json" {
bucket = var.bucket_registry_id
acl ... | SwissArmyRonin/terraform-aws-registry | MIT | modules/api-gateway/main.tf | aws | [
"aws_apigatewayv2_api",
"aws_apigatewayv2_integration",
"aws_apigatewayv2_route",
"aws_apigatewayv2_stage",
"aws_lambda_permission",
"aws_s3_bucket_object"
] | 2f52f892d99fa4f926c835417b37ee54 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with a name derived from a configurable suffix, enable versioning, enforce ownership controls, block all forms of public access, and set the bucket ACL to a specified value; configure it to serve a static website with a custom index document and optional error document; grant explicit public read ac... | ############################################
# DATA & LOCALS
############################################
data "aws_region" "current" {}
locals {
s3_bucket_name = (
var.s3_config.bucket_suffix == "" ?
var.s3_config.bucket_name :
"${var.s3_config.bucket_name}-${var.s3_config.bucket_suffix}"
)
}
#######... | tfstack/terraform-aws-s3-browser | MIT | main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_acl",
"aws_s3_bucket_cors_configuration",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_logging",
"aws_s3_bucket_ownership_controls",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3... | 4b79e1d6bc09c25545589839168792f4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSM parameter in the current AWS account and region, using a name derived from the environment (e.g., `/prod/database/password/master`) if no explicit name is provided, with the parameter type, value, description, tier, KMS key ID, overwrite behavior, and allowed pattern all configurable via variables, and en... | #-----------------------------------------------------------
# AWS SSM parameter
#-----------------------------------------------------------
resource "aws_ssm_parameter" "ssm_parameter" {
count = var.enable_ssm_parameter ? 1 : 0
name = var.ssm_parameter_name != "" ? lower(var.ssm_parameter_name) : "/${var.enviro... | SebastianUA/terraform | Apache-2.0 | aws/modules/ssm/ssm_parameter.tf | aws | [
"aws_ssm_parameter"
] | a2769c47af4e5100de099bc277459a04 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a deployer SSH key pair named “deployer-key” using the public key passed via the `deployer_key` variable, and provision a configurable number of compute instances (determined by `compute_count`) using the specified AMI, instance type, security groups, and subnet, each tagged with a name like “prefix001”, “prefix... | #------------------------------------------------------------------------------
#
#------------------------------------------------------------------------------
resource "aws_key_pair" "deployer" {
key_name = "deployer-key"
public_key = var.deployer_key
}
resource "aws_instance" "compute" {
ami ... | emanueleviale/terraform-test | MIT | main.tf | aws | [
"aws_instance",
"aws_key_pair"
] | 8bd13780b7b5ebfc0e7f3e358ae15b4b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a launch template for an EKS managed node group named according to the cluster ID and node group name, using a custom AMI if provided, with EBS volumes configured for encryption, optional KMS key, and configurable size/type/IOPS/throughput, enabling detailed monitoring, requiring instance metadata service tokens... | resource "aws_launch_template" "managed_node_groups" {
count = local.managed_node_group["create_launch_template"] == true ? 1 : 0
name = "${var.context.eks_cluster_id}-${local.managed_node_group["node_group_name"]}"
description = "Launch Template for EKS Managed Node Groups"
update... | kpskohli/test5 | Apache-2.0 | modules/aws-eks-managed-node-groups/managed-launch-templates.tf | aws | [
"aws_launch_template"
] | 224934bafc8708a4c39578d207172614 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Cognito user pool client named according to the `client_name` variable, associated with the main user pool, that generates a client secret and enables refresh token, user password, admin user password, custom, and SRP authentication flows, while only supporting Cognito as the identity provider. | resource "aws_cognito_user_pool_client" "main" {
name = var.client_name
user_pool_id = aws_cognito_user_pool.main.id
generate_secret = true
explicit_auth_flows = [
"ALLOW_REFRESH_TOKEN_AUTH",
"ALLOW_USER_PASSWORD_AUTH",
"ALLOW_ADMIN_USER_PASSWORD_AUTH",... | nicole-escobar-alves/backend-aws-infra | MIT | modules/cognito/user_pool_client.tf | aws | [
"aws_cognito_user_pool_client"
] | 09c69d269937509f3d4bf6c5eb45cf6e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with DNS support and hostnames enabled, named according to a variable, and provision a configurable number of public subnets across availability zones with public routing to the internet, a configurable number of private subnets in the same zones, and optional internal subnets tagged for Kubernetes interna... | resource "aws_vpc" "main" {
cidr_block = var.cidr_block
enable_dns_support = true
enable_dns_hostnames = true
tags = {
Name = var.vpc_name
}
}
resource "aws_subnet" "public" {
count = var.public_subnet_count
vpc_id = aws_vpc.main.id
cidr_block = elemen... | SergeDubovsky/argocd-eks-gitops | MIT | terraform/modules/vpc/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 74080a7a3e630a89e7903790d69c31d6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Open all TCP and UDP ports from 0 to 2376, 2377, 7946, 4789, 49153, 3000, 9090, and 9100 for both ingress and egress traffic to and from the security group, allowing unrestricted access from any IPv4 address (0.0.0.0/0), to support Docker Swarm cluster communication, overlay networking, and Prometheus/Grafana monitorin... | resource "aws_security_group_rule" "swarm_sgr_1" {
security_group_id = var.security_group_id
type = "ingress"
from_port = 0
to_port = 2376
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
resource "aws_security_group_rule" "swarm_sgr_2" {
security_group_id = var.security_group_id
typ... | rssoroka/devops_roman | Apache-2.0 | terraform/terraform_aws/modules/swarm-security-group/main.tf | aws | [
"aws_security_group_rule"
] | db1110249e28fdc7e2e0bbb8cfd1018d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an OpenSearch domain named according to the `opensearch_domain` variable, running version 1.3 with a single `t3.small.search` instance, 10 GB of GP3 storage, and access restricted to IAM users whose ARNs are derived from the `opensearch_user` field in the `microservices_config` variable. | resource "aws_opensearch_domain" "fcg" {
domain_name = var.opensearch_domain
engine_version = "OpenSearch_1.3"
cluster_config {
instance_type = "t3.small.search"
instance_count = 1
zone_awareness_enabled = false
}
ebs_options {
ebs_enabled = true
volume_size = 10
volum... | PauloBusch/fcg-iac-terraform | MIT | opensearch.tf | k8s | [
"aws_opensearch_domain"
] | 376f3a4dd8ca9ea545e93f42a0126020 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS service running on Fargate with a dedicated ECR repository for immutable images, configured to retain only the 50 most recent images, log to a CloudWatch log group named `/ecs/<name>` with 30-day retention, and expose specified ports via a load balancer using target groups with configurable health checks;... | /**
* # AWS ECS Service
* Creates ECS service with cloudwatch, ECR repository, task definition, load balancer and autoscaler.
* Its highly recommended to use `aws-ecs-service-permissions` with this module to create all necessary roles and policies.
*/
# -------------------------------------------------------------... | boldare/terraform-modules | MIT | modules/aws-ecs-service/main.tf | aws | [
"aws_appautoscaling_policy",
"aws_appautoscaling_target",
"aws_cloudwatch_log_group",
"aws_cloudwatch_log_stream",
"aws_ecr_lifecycle_policy",
"aws_ecr_repository",
"aws_ecs_service",
"aws_ecs_task_definition",
"aws_lb_listener",
"aws_lb_target_group",
"random_pet"
] | f1da1a449d6de3203df2b51cfe8298f6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS task definition named after the application with three host volumes: one for logs at `/var/log/<container_name>`, one for data at a specified host path, and one for keys at another specified host path, all defined via variables. | resource "aws_ecs_task_definition" "environment" {
family = "${var.app_name}-task-definition"
container_definitions = "${var.container_definitions}"
volume {
name = "log"
host_path = "/var/log/${var.container_name}"
}
volume {
name = "${var.data_volume_name}"
host_path = ... | ministryofjustice/hmpps-terraform-modules | MIT | modules/ecs/ecs-taskdefinitions/appwithdatavolume/main.tf | aws | [
"aws_ecs_task_definition"
] | df49c0d25b612b7e4bc539b0db1a9ecc |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a KMS key named with the alias `test-sns-cw` that enables key rotation, has a seven-day deletion window, and grants the CloudWatch service permission to decrypt data and generate data keys using it, while also allowing the account’s root IAM user full access; then provision an SNS topic named `test-sns-cw` that ... | #Ensure Cloudwatch has access to the KMS Key
data "aws_iam_policy_document" "ecs_alerts_key" {
statement {
sid = "Enable IAM User Permissions"
effect = "Allow"
actions = ["kms:*"]
resources = ["*"]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${local.accoun... | narmitag/cloudwatch | Apache-2.0 | sns.tf | aws | [
"aws_kms_alias",
"aws_kms_key",
"aws_sns_topic"
] | c08b6861bf8ce1af8eb54367aea1e530 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a private S3 bucket named using the bucket prefix, stage, and the suffix “terraform-remote-state” to store Terraform state, and provision a DynamoDB table named “terraform-lock” followed by the lowercase stage name with read and write capacity of 1 each to serve as a state lock, using the “LockID” attribute as t... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = var.region
}
resource "aws_s3_bucket" "private_bucket" {
bucket = "${var.bucket_prefix}terraform-remote-state-${var.stage_lower}"
acl = "private"
tags = {
Name = "${var.bucket_p... | leonaaraujo/iac | MIT | src/terraform/1-remote-bucket/main.tf | aws | [
"aws_dynamodb_table",
"aws_s3_bucket"
] | 1e658b213cd3607aa87aa2f3d1ba573e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a MySQL database instance running version 8.0 on a db.t2.micro instance with 10 GB of storage, named "pets", using the username "admin" and a randomly generated 16-character password that includes special characters from the set _ % @ / ' . | resource "random_password" "password" {
length = 16
special = true
override_special = "_%@/'"
}
resource "aws_db_instance" "database" {
allocated_storage = 10
engine = "mysql"
engine_version = "8.0"
instance_class = "db.t2.micro"
identifier ... | ximinggao/terraform-in-action-solutions | MIT | chapter-4/modules/database/main.tf | aws | [
"aws_db_instance",
"random_password"
] | 14678b8c2caaac16bee0e0f87a784ef9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named redshift-vpc with a CIDR block defined by the variable vpc_cidr, attach an internet gateway named redshift-igw to it, configure the default security group in that VPC to allow inbound TCP traffic on port 5439 from any IP address (0.0.0.0/0), provision two public subnets named redshift-subnet-1 and re... | ##Create the new VPC for our redshift cluster.##
resource "aws_vpc" "redshift_vpc" {
cidr_block = var.vpc_cidr
instance_tenancy = "default"
tags = { Name = "redshift-vpc" }
}
##Now, We will define an internet gateway that we can attach to our VPC. After this, We can easily access this from the internet##
re... | amir-projects/redshift-tfc | MIT | resource.tf | aws | [
"aws_default_security_group",
"aws_iam_role",
"aws_iam_role_policy",
"aws_internet_gateway",
"aws_redshift_cluster",
"aws_redshift_subnet_group",
"aws_subnet",
"aws_vpc"
] | 81a34e1287af90ce18cdca59fc694c33 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a number of EC2 instances equal to the length of the `names` variable, each using AMI `ami-03c78641af2c4ba60`, instance type `t2.micro`, and a public IP; launch them in the first public subnet of the VPC tagged “Dev VPC”, assign them the IAM instance profile at the corresponding index from `var.instance_profi... | data "aws_vpc" "this" {
tags = {
Name = "Dev VPC"
}
}
data "aws_subnets" "this" {
filter {
name = "vpc-id"
values = [data.aws_vpc.this.id]
}
filter {
name = "map-public-ip-on-launch"
values = [true]
}
}
data "aws_security_group" "this" {
name = "Dev-Bastion"
vpc_id = data.... | jeffwhite06/vault-wex | Unlicense | modules/instance/main.tf | aws | [
"aws_instance"
] | cc7c66ad03acbedd083cc7c0384e6804 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS cluster with a name specified by a variable, enable or disable CloudWatch Container Insights based on another variable, and configure the cluster to use FARGATE and FARGATE_SPOT as capacity providers with a default strategy that routes 100% of tasks to the provider specified by a variable, starting with a... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
resource "aws_ecs_cluster" "this" {
name = var.cluster_name
setting {
name = "containerInsights"
value = var.container_insights ? "enabled" : "disabled"
}
}
resource "aws_ecs_cluster_capacity_providers" "defaul... | danbarr/terraform-aws-ecs-fargate-cluster | MIT | main.tf | aws | [
"aws_ecs_cluster",
"aws_ecs_cluster_capacity_providers"
] | 015ebf08d48eaabf5a8fadf1399ea09c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Airflow deployment infrastructure in AWS including a PostgreSQL database for metadata (version 13.7, db.t3.medium, 20 GB storage, 7-day backup retention), a Redis cache for Celery (cache.t3.micro, single node), an S3 bucket with versioning enabled for DAGs and logs, an EKS cluster node group with 1–5 nodes (d... | # Random password for RDS
resource "random_password" "db_password" {
length = 16
special = true
}
# Security group for Airflow components
resource "aws_security_group" "airflow" {
name_prefix = "airflow-${var.environment}-"
vpc_id = var.vpc_id
egress {
from_port = 0
to_port = 0
proto... | cloudon-one/k8s-platform-modules | MIT | k8s-platform-airflow/main.tf | aws | [
"aws_db_instance",
"aws_db_subnet_group",
"aws_eks_node_group",
"aws_elasticache_cluster",
"aws_elasticache_subnet_group",
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment",
"aws_s3_bucket",
"aws_s3_bucket_versioning",
"aws_security_group",
"random_password"
] | 7b8d57f18ae5e58d2708a5a9fca4ed6d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “rds-vpc” with a 10.0.0.0/16 CIDR block, DNS hostnames and DNS support enabled, and deploy two public subnets named “rds-public-subnet-1” and “rds-public-subnet-2” in separate availability zones with 10.0.1.0/24 and 10.0.2.0/24 CIDR blocks respectively, each configured to assign public IP addresses t... | resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "rds-vpc"
}
}
# RDS requires at least two AZ subnets
resource "aws_subnet" "public_1" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1... | xaviernogueira/aws-forgejo-quickstart | MIT | infra/network.tf | aws | [
"aws_db_subnet_group",
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 4c9d3a969bc83d9ef40c911a114c088b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role policy named “Allow-[lambda_name]-sns-access” attached to the role specified by [lambda_role_name] that permits the Lambda function to create and publish to the SNS topics listed in [sns_topic_arns_with_name]. | resource "aws_iam_role_policy" "lambda_policy" {
name = "Allow-${var.lambda_name}-sns-access"
role = var.lambda_role_name
policy = data.aws_iam_policy_document.lambda_policy.json
}
data "aws_iam_policy_document" "lambda_policy" {
statement {
actions = ["sns:CreateTopic", "sns:Publish"]
effect ... | xorima/terraform-aws-lambda-sns-iam-permissions | Apache-2.0 | main.tf | aws | [
"aws_iam_role_policy"
] | 347044209d9402505f8a98727f0272c1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EFS file system with the creation token “cloudrail-test” in us-east-1, and define an ECS task family named “cloudrail-test-encryption” that runs two essential containers—“first” using image “service-first” with 10 CPU units and 512 MiB memory, and “second” using image “service-second” with 10 CPU units and 25... | provider "aws" {
region = "us-east-1"
}
resource "aws_efs_file_system" "test" {
creation_token = "cloudrail-test"
}
resource "aws_ecs_task_definition" "service" {
family = "cloudrail-test-encryption"
container_definitions = <<DEFINITION
[
{
"name": "first",
"image": "service... | cysk92/ck-demo | BSD-3-Clause | test/aws/terraform/ensure_ecs_task_definition_created_with_efs_encrypt_in_transit_rule/task_definition_not_encrypted_in_transit/main.tf | aws | [
"aws_ecs_task_definition",
"aws_efs_file_system"
] | 992ff066241950e3ae1bf537a1e94310 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a MySQL database instance named bookdb-instance using version 8.0.42 of the engine, sized as a db.t3.medium with 20 GB of gp3 storage, deployed across two Availability Zones for high availability, configured with a private subnet group spanning subnets 5a and 6b, secured by a specified security group, and explic... | resource "aws_db_subnet_group" "db_subnet" {
name = var.db_sub_name
subnet_ids = [var.priv_sub_5a_id, var.priv_sub_6b_id] # Replaced with private subnet IDs
}
resource "aws_db_instance" "db" {
identifier = "bookdb-instance"
engine = "mysql"
engine_version ... | ImRaNM-001/terraform-journals | MIT | Task-7-deploy-app-ALB/modules/rds/main.tf | aws | [
"aws_db_instance",
"aws_db_subnet_group"
] | 3b870e4b47b8a60470e93543cb530f71 |
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 `<appname>-frontend` that pulls source code from a CodeCommit repository named `<appname>-sitecode` on the `master` branch, triggers builds on branch pushes (without polling), compiles the frontend using a CodeBuild project named `<appname>-frontend` with a 5-minute timeout and a standard ... |
resource "aws_codepipeline" "frontend" {
name = "${var.appname}-frontend"
role_arn = aws_iam_role.codepipeline.arn
artifact_store {
location = aws_s3_bucket.codepipeline.bucket
type = "S3"
}
stage {
name = "Source"
action {
name = "Source"
category = ... | mouckatron/aws-static-website | MIT | codepipeline.tf | aws | [
"aws_cloudwatch_event_rule",
"aws_cloudwatch_event_target",
"aws_codebuild_project",
"aws_codepipeline"
] | 80a29f2efb73a9396ef56e4b1a5500a4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Step Functions state machine named “hello-sfn-fargate-task” in us-west-2 that runs an ECS Fargate task synchronously using a specific cluster and task definition, with the task’s network configuration set to use default subnets and assign a public IP; provision an IAM role for Step Functions named “hello-sfn-f... | resource "aws_sfn_state_machine" "sfn" {
name = "hello-sfn-fargate-task"
role_arn = aws_iam_role.sfn.arn
definition = jsonencode(
{
"StartAt" : "RunTask",
"States" : {
"RunTask" : {
"Type" : "Task",
"Resource" : "arn:aws:states:::ecs:runTask.sync",
"Parame... | int128/hello-sfn | Apache-2.0 | fargate-task/sfn.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy",
"aws_sfn_state_machine"
] | f8401a5741348120faef6179eaf15bfd |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two NAT gateways, one in Availability Zone us-east-1a and another in us-east-1b, each associated with a dedicated elastic IP and placed in the respective public subnets subnet-pub-1a and subnet-pub-1b, and tag both with the project name and a unique identifier for the NAT gateway. | resource "aws_nat_gateway" "nat-gateway-pub-1a" {
allocation_id = aws_eip.elastic-ip-1a.id
subnet_id = aws_subnet.subnet-pub-1a.id
tags = merge(
var.tags,
{
Name = "${var.project_name}-nat-gateway-pub-1a"
Project = "${var.project_name}"
}
)
}
resource "aws_nat_gateway" "nat-gate... | thdesous/aws-eks-cluster | MIT | infra/modules/network/nat-gateway-public.tf | aws | [
"aws_nat_gateway"
] | e5c761fdde0fbf77928ec8282fd43478 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a DynamoDB table named `terraform_locks` to manage state locking, then add a five-second delay before running a local script called `gen-backend.sh` that generates backend configuration, ensuring the script only executes after the DynamoDB table is fully created. | resource "null_resource" "gen_backend" {
triggers = {
always_run = timestamp()
}
depends_on = [null_resource.sleep]
provisioner "local-exec" {
when = create
command = "./gen-backend.sh"
}
}
resource "null_resource" "sleep" {
triggers = {
always_run = timestamp()
}
depends_on = [aws_dynamodb_table.terr... | bmutziu/eks-blueprint | MIT-0 | tf-setup/null_resource.tf | aws | [
"null_resource"
] | 14eaeb5e3bd4ae8e50d50072446b5ddf |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SQS queue named with the environment variable suffixed by `-cloudtrail-log-queue`, configured with managed encryption, 256 KB maximum message size, 4-day message retention, and 30-second visibility timeout; configure the S3 bucket used for CloudTrail logging to send notifications to this queue whenever new ob... | #### Cloudtrail
data "aws_s3_bucket" "cloudtrail_logging" {
bucket = local.cloudtrail_bucket
}
resource "aws_sqs_queue" "cloudtrail_logging" {
name = "${var.environment_name}-cloudtrail-log-queue"
sqs_managed_sse_enabled = true # Using managed encryption
delay_seconds = ... | ministryofjustice/hmpps-delius-network-terraform | MIT | xsiam-logging/cloudtrail.tf | aws | [
"aws_s3_bucket_notification",
"aws_sqs_queue",
"aws_sqs_queue_policy"
] | 3e5e48110c1e09661ddf13fd908df2dd |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an EC2 instance named “dropvault” using the AMI ID `ami-0f8e81a3da6e2510a`, with an instance type and root volume size defined by variables, attached to a public subnet and configured with a key pair named `tf-key-pair`, a security group allowing all inbound and outbound traffic, and an IAM instance profile g... | resource "aws_instance" "dropvault" {
ami = var.ami_id
instance_type = var.aws_config.instance_type
key_name = aws_key_pair.tf-key-pair.key_name
security_groups = ["${aws_security_group.ingress-all-test.id}"]
vpc_security_group_ids = ["... | johncarmack1984/deep-freeze-aws-architecture | MIT | servers.tf | aws | [
"aws_instance"
] | 2d4f20e2bcca1c6135ac1f41e0947100 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a Puppet Enterprise primary server instance in a public subnet with a 4096-bit RSA SSH key pair generated and stored locally, assign it a randomly generated 8-character alphanumeric admin password, configure a security group allowing SSH, HTTPS, ICMP, and Puppet-specific ports (4433, 5432, 8081, 8140, 8142, 8... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
random = {
source = "hashicorp/random"
}
tls = {
source = "hashicorp/tls"
}
}
}
# create ssh key for pe_primary aws instance
resource "tls_private_key" "ssh_private_key" {
algorithm = "RSA"
rsa_bits... | dbr787/puppetize-21-terraform | MIT | modules/puppet-enterprise/main.tf | aws | [
"aws_alb",
"aws_alb_listener",
"aws_alb_target_group",
"aws_alb_target_group_attachment",
"aws_instance",
"aws_key_pair",
"aws_route53_record",
"aws_security_group",
"random_string",
"tls_private_key"
] | fc49d3cf26f4d590f08e8ba790b041dc |
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 provision a public and private subnet in each available zone in the region. Attach an internet gateway to the VPC and configure a public route table with a default route to the internet gateway, associating all public subnets with... | # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones
data "aws_availability_zones" "azs" {}
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc
resource "aws_vpc" "vpc" {
cidr_block = var.vpc_cidr_block
instance_tenancy = "d... | VoskhodXIV/infrastructure | MIT | modules/vpc/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | e1aa58c1902021a98e475b0fbc7c70c4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC in the sa-east-1 region with DNS hostnames enabled, using a CIDR block defined per environment (defaulting to 10.0.0.0/16), and name it with the current workspace suffix. Provision three public subnets across availability zones sa-east-1a, sa-east-1b, and sa-east-1c, each with a /24 CIDR derived from the V... | resource "aws_vpc" "vpc" {
cidr_block = lookup(var.environment_configs[terraform.workspace], "vpc_cidr", "10.0.0.0/16")
instance_tenancy = "default"
enable_dns_hostnames = true
tags = {
Name = "${terraform.workspace}-vpc"
Environment = terraform.workspace
}
}
resource "aws_subnet" ... | LuizHbatista1/for-challenge-medcloud | MIT | infra/terraform/vpc.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | 55feca235ae2a326e02d22641e43d9c0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Secrets Manager secret named according to the variable, encrypted with a KMS key that has rotation enabled and an alias matching the secret’s name, with an initial secret value provided, and configure fine-grained access policies: one admin principal group with broad permissions excluding read operations, one ... | resource "aws_secretsmanager_secret" "this" {
description = var.description
kms_key_id = aws_kms_key.this.arn
name = var.name
tags = var.resource_tags
}
resource "aws_secretsmanager_secret_policy" "this" {
secret_arn = aws_secretsmanager_secret.this.arn
policy = data.aws_iam_policy_docum... | thoughtbot/terraform-aws-secrets | MIT | secret/main.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_kms_alias",
"aws_kms_key",
"aws_secretsmanager_secret",
"aws_secretsmanager_secret_policy",
"aws_secretsmanager_secret_version"
] | a751239532126d3b4a271bb96f4331c1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a single EC2 instance using the specified AMI and instance type, assign it a public IP, place it in the given subnet with the specified security group and IAM instance profile, use the provided SSH key, enable detailed metadata endpoint with required session tokens, disable detailed monitoring, enable EBS opt... | locals {
user_data = "${path.module}/userdata/${var.user_data_file}"
}
resource "aws_instance" "default" {
ami = var.ami
instance_type = var.instance_type
associate_public_ip_address = true
subnet_id = var.subnet_id
vpc_security_group_ids = [var.security_group_id]
iam_in... | epomatti/azure-defender-for-cloud | MIT | aws/modules/ec2/main.tf | aws | [
"aws_instance"
] | 2f59250850b51051d00a4863a64f4ff5 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Route 53 public hosted zone for a subdomain formed by appending the value of `subdomain_name` to `basedomain_name`, using the hashicorp/aws provider. | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
resource "aws_route53_zone" "subdomain" {
name = "${var.subdomain_name}.${var.basedomain_name}"
} | ko07ga/tf-aws-route53-subdomain-hostzone | MIT | modules/route53/subdomain_zone/main.tf | aws | [
"aws_route53_zone"
] | 2e6e5246f29da8eeb5a0d5dfea7b629a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with a 10.0.0.0/16 CIDR block, including one Internet Gateway, two public subnets (one per availability zone, each with auto-assigned public IPs), two private subnets (one per availability zone), four security groups named elb_sg_<environment>, ec2_sg_<environment>, rds_sg_<environment>, and redis_sg_<envi... | /**
*## Description:
*
*VPC module creates a VPC in the region used in the AWS provider with:
*
** 1 Internet gateway
** 2 Public subnets (one in each availability zone)
** 2 Private subnets (one in each availability zone)
** 4 Security groups (elb, rds, ec2, redis)
** VPC Subnet Group
*
*## Usage:
*
*```h... | debtcollective/infra | BSD-3-Clause | modules/network/vpc/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | e84ab36c210b0e425c9069eb9586137d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a load balancer listener rule that evaluates incoming requests using configurable conditions such as host headers, path patterns, HTTP method, query strings, source IP, and custom HTTP headers, and then performs one or more actions—fixed response, forwarding to weighted target groups with optional stickiness, or... | /* Load balancer listener rule */
resource "aws_lb_listener_rule" "lb_listener_rule" {
listener_arn = var.listener_arn
priority = var.priority
dynamic "action" {
for_each = var.actions
content {
type = action.value["type"]
target_group_arn = action.value["target_group_arn"]
... | StamenchoBog/smart-home | MIT | external_systems/infra/terraform/aws/modules/load_balancer_listener_rule/main.tf | aws | [
"aws_lb_listener_rule"
] | bddd09a313b4af07720062fb9a470a7a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Virtual Private Cloud with a user-defined CIDR block, enable DNS support and hostnames, assign an IPv6 CIDR block, tag it with a configurable name and environment, and output its ID, IPv4 CIDR, and IPv6 CIDR. | #--------------------------------------------------------------
# This module creates all resources necessary for a VPC
#--------------------------------------------------------------
variable "name" {
default = "vpc"
}
variable "cidr" {
}
variable "environment" {
}
resource "aws_vpc" "vpc" {
cidr_block ... | toff63/aws_setup_template | MIT | ops/terraform/modules/network/vpc/vpc.tf | aws | [
"aws_vpc"
] | affa63846b3c8f11eb545125ddefd011 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EKS cluster named EKS_CLOUD in the default VPC, using only subnets located in the us-east-1a, us-east-1b, us-east-1c, us-east-1d, or us-east-1f availability zones, with a dedicated IAM role for the cluster that has the AmazonEKSClusterPolicy attached. Also provision a managed node group named Node-cloud with ... | # Get default VPC
data "aws_vpc" "default" {
default = true
}
# Get all subnets in the VPC
data "aws_subnets" "all" {
filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}
# Get supported availability zones
data "aws_availability_zones" "available" {
state = "available"
filter {
name... | Dinesh-Arivu/Ultimate-CI-CD-Deploy-Java-Application-using-Jenkins-Maven-SonarQube-Docker-Argo-CD-and-Kubernetes | Apache-2.0 | EKS_TERRAFORM_NORTH_VIRGINIA_REGION/main.tf | aws | [
"aws_eks_cluster",
"aws_eks_node_group",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | cab80ea211f1d29bbe8b41d147a2bf42 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a VPC with CIDR 172.20.0.0/16, an internet gateway, a single subnet in the specified availability zone with CIDR 172.20.0.0/24, and a route table routing all traffic (0.0.0.0/0) through the internet gateway to that subnet. Launch a t2.micro EC2 instance using AMI ami-08ca3fed11864d6bb in the subnet with a pub... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
backend "s3" {
bucket = "next-level-cxt-tfstate"
key = "lab-05-tfstate"
region = "eu-west-1"
profile = "cxt"
}
}
provider "aws" {
profile = "cxt"
region = "eu-west-1"
}
#
# Variables
#
variable "... | jorgeteixe/next-level-CXT | MIT | 05-data-security/10-terraform/main.tf | aws | [
"aws_ebs_volume",
"aws_instance",
"aws_internet_gateway",
"aws_key_pair",
"aws_route53_record",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_volume_attachment",
"aws_vpc"
] | dfe0572892a63398b535771e7a4b5490 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create three S3 buckets: one for input files (PDFs and Excel) with versioning, AES256 encryption, a lifecycle policy that moves files to Standard-IA after 90 days and to Glacier after 180 days, and folders for uploads/api/, uploads/direct/, and uploads/console/; one for output CSV files with versioning and AES256 encry... | locals {
input_bucket_name = var.input_bucket_name != null ? var.input_bucket_name : "${var.project_name}-input-${var.environment}-${random_string.bucket_suffix.result}"
output_bucket_name = var.output_bucket_name != null ? var.output_bucket_name : "${var.project_name}-output-${var.environment}-${random_st... | eulerianKnight/genai-doc-to-db | Apache-2.0 | infrastructure/modules/storage/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_cors_configuration",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning",
"aws_s3_object",
"random_string"
] | 6fb671b7ab010d077b771c74be3f4092 |
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 tags. Provision public subnets in each availability zone with automatic public IP assignment on launch, and private subnets without it. Attach an internet gateway to the VPC, and if NAT gateways are enabled, deploy one per public s... | ## File: main.tf
resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = var.enable_dns_hostnames
enable_dns_support = var.enable_dns_support
tags = merge(
var.tags,
{
Name = var.vpc_name
}
)
}
resource "aws_subnet" "public" {
count ... | jaaparjazzery/aws-terraform-modules | MIT | modules/vpc/main.tf | aws | [
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 918907b7c65ccc9a157ec2c9dbcfd91d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy named “privesc-AssumeRole-high-priv-policy” with full administrative permissions (allowing all actions on all resources), attach it to an IAM role named “privesc-AssumeRole-ending-role”, set up a chain of three IAM roles—“privesc-AssumeRole-starting-role”, “privesc-AssumeRole-intermediate-role”, an... | resource "aws_iam_policy" "privesc-AssumeRole-high-priv-policy" {
name = "privesc-AssumeRole-high-priv-policy"
path = "/"
description = "Allows privesc via targeted sts:AssumeRole"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
policy = json... | BishopFox/iam-vulnerable | MIT | modules/free-resources/privesc-paths/privesc-AssumeRole.tf | aws | [
"aws_iam_access_key",
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_iam_user"
] | 5c0bdf0e50dd67315f50d09c20eba759 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with a single CIDR block, two subnets in the same Availability Zone, a security group with configurable ingress and egress rules keyed by index, an internet gateway attached to the VPC, a route table with a default route to the internet gateway, and associate each subnet with the route table—use the provid... | locals {
name_prefix = var.network_config.name_prefix
ingress_sg_rules_map = { for idx, rule in var.network_config.sg_rules.ingress : idx => rule }
egress_sg_rules_map = { for idx, rule in var.network_config.sg_rules.egress : idx => rule }
vpc_name = var.network_config.vpc_name
subnet_na... | sumanthreddy29/telescope | MIT | modules/terraform/aws/virtual-network/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | ff3ea197b2948ffb9861cd61f8d166ad |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create two KMS keys—one for S3 data lake encryption and one for Glue Catalog encryption—each with a user-friendly alias, key rotation enabled, a configurable deletion window, and policies that grant full access to the account root, allow S3 and Glue services to use the keys only for their respective services, and optio... | # AWS Data Lake Encryption Module
# Creates KMS keys and IAM policies for data lake encryption and service isolation
# Data sources
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
# S3 KMS Key for data-at-rest encryption
resource "aws_kms_key" "s3" {
description = "KMS key for S3 ... | nanlabs/terraform-aws-modules | MIT | modules/aws-data-lake-encryption/main.tf | aws | [
"aws_cloudtrail",
"aws_iam_policy",
"aws_kms_alias",
"aws_kms_key"
] | 27c9c56ad9c857c81632d0e5e179da6b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS service named with the active color prefix (blue or green) that runs tasks using a replica scheduling strategy, places them across private subnets with a single security group, attaches to a load balancer target group only when enabled, and uses a service discovery namespace and DNS registry when service ... | resource "aws_ecs_service" "service" { # when blue/green this is blue
name = var.enable_blue_green_deployment ? local.name_prefix_blue : local.name_prefix
cluster = var.ecs_cluster_id
task_definition = var.task_definition_arn
enable_ecs_managed_tags = true
scheduling_strategy = "REPLIC... | josefloressv/cicd_demo_github_in_actions | Apache-2.0 | terraform/modules/app/main.tf | aws | [
"aws_ecs_service"
] | 4ccd0da1d35c52511a158000d80380b6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group named “foundry-instance” that permits inbound TCP traffic on ports 30000 and 443 from any IP address, allows all outbound traffic, and tag it as “Foundry Instance SG”; also create a security group named “foundry-efs” that permits inbound NFS traffic (port 2049/TCP) only from itself, allows all o... | resource "aws_security_group" "foundry_instance" {
name = "foundry-instance"
description = "Security group allowing ingress to the instance"
ingress {
description = "Default traffic on port 30000"
from_port = 30000
to_port = 30000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress ... | jkjn/foundryvtt | Apache-2.0 | provisioning/server/security-groups.tf | aws | [
"aws_security_group"
] | 5f383fe67712388fe04effb57b486df7 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EFS mount target for the specified file system, deploying one per subnet in the provided list of subnet IDs, using the given IP address and security groups, and ensure it is created before any existing resource it depends on is destroyed. | #---------------------------------------------------
# AWS EFS mount target
#---------------------------------------------------
resource "aws_efs_mount_target" "efs_mount_target" {
count = var.enable_efs_mount_target && length(var.efs_mount_target_subnet_ids) > 0 ? length(var.efs_mount_target_subnet_ids) : 0
file... | SebastianUA/terraform | Apache-2.0 | aws/modules/efs/efs_mount_target.tf | aws | [
"aws_efs_mount_target"
] | 2467d88e9830cd089549ac3a0185aec3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named KafkaConnectRole-[eks_cluster_name] that can be assumed by the Kubernetes service account `kafka-connect` in the `kafka-system` namespace via OIDC federation with the EKS cluster’s OIDC provider, and attach to it a policy named KafkaClusterAllowPolicy-[eks_cluster_name] that grants permissions ... |
resource "aws_iam_role" "kafka_connect" {
name = "KafkaConnectRole-${var.eks.name}"
assume_role_policy = data.aws_iam_policy_document.eks_oidc_kafka_connect_assume_role.json
}
data "aws_iam_policy_document" "eks_oidc_kafka_connect_assume_role" {
version = "2012-10-17"
statement {
actions = ... | lomeone/IaC-modules | MIT | aws/iam/service-account/kafka-connect.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 654cd94c7d6de384a19cd6747e702298 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudWatch Event Rule named “aggregator-import-ecs-state-change” that triggers on ECS task state changes for tasks in the “aggregator” cluster with the task group “family:aggregator-import” when they reach STOPPED status, and configure it to send events to a specific Lambda function. Set up a CloudWatch Log Gr... | resource "aws_cloudwatch_event_rule" "aggregator_import_state" {
depends_on = [aws_lambda_function.lambda]
name = "aggregator-import-ecs-state-change"
description = "Get each time a aggregator import starts/stops"
event_pattern = jsonencode({
source = ["aws.ecs"]
detail-type = ["ECS Task S... | bmlt-enabled/aggregator-failed-import-notifier | MIT | terraform/cloudwatch.tf | aws | [
"aws_cloudwatch_event_rule",
"aws_cloudwatch_event_target",
"aws_cloudwatch_log_group"
] | 49324860a04f30db1e8c5b3c2d82dd34 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a primary VPC in us-east-1 with a 10.0.0.0/16 CIDR block, six public subnets spanning availability zones 1a through 1f each with a /20 CIDR and automatic public IP assignment on launch, an internet gateway attached to the VPC, and a configurable number of Elastic IPs based on the eip_count variable. | resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
tags = {
Name = "main"
Description = "This is the primary VPC used by the SOTW app."
}
}
resource "aws_subnet" "ecs_1a" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.0.0/2... | Song-of-the-Week/SongOfTheWeekInfra | Apache-2.0 | modules/network/main.tf | aws | [
"aws_eip",
"aws_internet_gateway",
"aws_subnet",
"aws_vpc"
] | bd8e1b9cf0ac7d14c01aac4389bdafd6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Amazon SES domain identity for the domain specified in the `domain` variable, and add a TXT record in the Route 53 zone identified by the `zone` variable to verify domain ownership, using the verification token provided by SES as the record name, with a TTL of 30 seconds. | provider "aws" {
region = var.region
}
resource "aws_ses_domain_identity" "domain" {
domain = var.domain
}
resource "aws_route53_record" "verification_token_mx" {
zone_id = var.zone
name = aws_ses_domain_identity.domain.verification_token
type = "TXT"
ttl = "30"
records = ["_amazonses.${aws_se... | virsas/terraform_ses_domain | MIT | main.tf | aws | [
"aws_route53_record",
"aws_ses_domain_identity"
] | c6950087693e8def64463519719e4e1d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with the CIDR block and name specified in `var.network_info`, provision public subnets in the availability zones and CIDR blocks defined in `var.network_info.public_subnets`, attach them to a public route table that routes all traffic (0.0.0.0/0) to an internet gateway, and provision private subnets in the... | #vpc
resource "aws_vpc" "base" {
cidr_block = var.network_info.cidr
tags = {
Name = var.network_info.name
Env = "dev"
}
}
resource "aws_internet_gateway" "base" {
count = local.has_public_subnets ? 1 : 0
vpc_id = aws_vpc.base.id
tags = {
Name = var.network_info.name
}
}
resource "aws_route_... | Sachinkumar139/Terraform | Apache-2.0 | aws/network/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 563ed2be9f3bf00cdd99f60bf9dd798f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an MX record and a TXT record in the specified Route 53 hosted zone for the given DNS name, with a TTL of 300 seconds, where the MX record points to mx1.improvmx.com (priority 10) and mx2.improvmx.com (priority 20), and the TXT record contains the SPF record “v=spf1 include:spf.improvmx.com ~all” to enable email... | variable route53_hosted_zone_id {
description = "The Zone ID in which to create the record."
}
variable route53_hosted_zone_dns_name {
description = "The DNS name to use."
}
resource "aws_route53_record" "mail_forwarding_mx_route53_record" {
zone_id = var.route53_hosted_zone_id
name = var.route53_hoste... | julb/aws-infrastructure | MIT | production/mail-forwarding/main.tf | aws | [
"aws_route53_record"
] | 9303cc692e4a411812d5ad3491ccca21 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `eks-<cluster_name>-cluster-ServiceRole` for the EKS cluster control plane that allows EKS and EKS Fargate pods to assume it, attach the AWS managed `AmazonEKSClusterPolicy` and `AmazonEKSVPCResourceController` policies, and add inline policies granting CloudWatch metrics publishing and ELB-rel... | resource "aws_iam_role" "eks" {
name = "eks-${var.cluster_name}-cluster-ServiceRole"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${local.account_id}:root",
"Service": [
"eks.amazonaws.... | g-lok/terraform-python-util | Apache-2.0 | modules/eks/iam.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment"
] | e481f436dcccd5fea63ccf6fda89678d |
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 GitHub Actions that uses the URL specified in `var.url`, includes `sts.amazonaws.com` as a client ID if no custom list is provided, and sets the TLS certificate thumbprint using the SHA-1 fingerprint from the certificate retrieved from that URL. Only create this provider if `var.cr... | data "tls_certificate" "thumbprint" {
count = var.create_provider ? 1 : 0
url = var.url
}
resource "aws_iam_openid_connect_provider" "github" {
count = var.create_provider ? 1 : 0
url = var.url
client_id_list = coalescelist(var.client_id_list, ["sts.amazonaws.com"])
thumbprint_list = data.tls_certifica... | truemark/terraform-aws-github-oidc-provider | BSD-3-Clause | main.tf | aws | [
"aws_iam_openid_connect_provider"
] | 04df4a338c5cc69c64d3c094a15fb305 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a static IP address in the current AWS region (us-east-1), tagged with the environment and project name, the owner, project owner, city (Minsk), country (Belarus), the list of availability zones in the region, and a descriptive location string listing the region and its availability zones. | #--------------------------------------------------------
# Locals
#
# Позволяет обращаться к переменным в локальном окружении
#--------------------------------------------------------
provider "aws" {
region = "us-east-1"
}
data "aws_region" "current" {}
data "aws_availability_zones" "available" {}
locals {
fu... | AlexeyTozik/SkillForge | MIT | Terraform/Practice/Lesson-20/main.tf | aws | [
"aws_eip"
] | 88ed015b9f442fdda2e79d535d17a6e2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with the name specified in `var.bucket_name`, tagged using `var.tags`, and configured with private access control, versioning enabled, AES256 server-side encryption by default, and a lifecycle rule that aborts incomplete multipart uploads after 2 days and deletes noncurrent object versions after 90 ... | # Define S3 resources.
# https://aws.amazon.com/s3
# https://www.terraform.io/docs/providers/aws/d/iam_role.html
data "aws_iam_role" "main" {
name = var.role_name
}
# https://www.terraform.io/docs/providers/aws/r/s3_bucket.html
resource "aws_s3_bucket" "main" {
# The name of the bucket.
bucket = var.bucket_name... | wurde/terraform-backend-s3 | MIT | s3.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_policy"
] | 448a61a071bfe998426573a2fb1ad29d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group for an Application Load Balancer that allows inbound TCP traffic on the application port and port 443 from anywhere, and permits all outbound traffic. Create a second security group for ECS tasks that allows inbound SSH (port 22) from the VPC’s CIDR block (10.0.0.0/16) and inbound traffic on the... | # security.tf
# ALB Security Group: Edit to restrict access to the application
resource "aws_security_group" "lb" {
name = "${var.project}-load-balancer-security-group"
description = "controls access to the ALB"
vpc_id = var.vpc_id
ingress {
protocol = "tcp"
from_port = var.app_port
... | RyanOatz99/terraform-aws-fargate-efs | MIT | security.tf | aws | [
"aws_security_group"
] | 6f9d0d89c0dffd975d6bbc385917d2d6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Request an SSL/TLS certificate for the application domain and its wildcard subdomain, using DNS validation via the provided Route 53 hosted zone, and ensure the validation records are automatically created and the certificate is fully validated. | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
resource "aws_acm_certificate" "this" {
domain_name = "${var.app_name}.${var.hosted_zone_name}"
subject_alternative_names = ["*.${var.app_name}.${var.hosted_zone_name}"]
validation_method = "DNS"
... | langburd/devops-assignment | MIT | modules/aws/acm/main.tf | aws | [
"aws_acm_certificate",
"aws_acm_certificate_validation",
"aws_route53_record"
] | e431228cd978c339e0c5d1fa01d9a922 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `terraform-states-soham` in `us-east-2` to store Terraform state, with state locking via a DynamoDB table of the same name and encryption enabled for the state file; also provision a MySQL database instance with 10 GB storage, `db.t2.micro` instance class, identifier prefix `terraform`, databa... | terraform {
backend "s3" {
bucket = "terraform-states-soham"
key = "stage/data-stores/mysql/terraform.tfstate"
region = "us-east-2"
dynamodb_table = "terraform-states-soham"
encrypt = true
}
}
provider "aws" {
region = "us-east-2"
}
resource "aws_db_instance" "example" {
instance_class = ... | sohamrajput7/terraform-examples | MIT | 02-terraform-state/file-layout-example/stage/data-stores/mysql/main.tf | aws | [
"aws_db_instance"
] | 7bc9731ba8be6908b6fa77a254717b0b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an internet gateway named “Internet Gateway” and attach it to the VPC called “My_VPC”. | # Configura uma gateway para a vpc
resource "aws_internet_gateway" "My_VPC_GW" {
vpc_id = aws_vpc.My_VPC.id
tags = {
Name = "Internet Gateway"
}
} | robertoleao/aws_terraform | MIT | internet_gateway.tf | aws | [
"aws_internet_gateway"
] | 2db191692865e91e22aed5cb5ea47870 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy with a name provided via the `lambda_deploy_iam_policy_name` variable that grants permissions to push images to a specific ECR repository, obtain an ECR authorization token, and perform all Lambda actions on a specific Lambda function; also create an IAM role trust policy allowing the Lambda servic... | variable "lambda_deploy_iam_policy_name" {}
data "aws_iam_policy_document" "allow_push_ecr" {
statement {
sid = "AllowPushEcr"
effect = "Allow"
actions = [
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayer... | ryoma116/aws-lambda-deploy | MIT | environment/terraform/modules/aws/iam_policy.tf | aws | [
"aws_iam_policy"
] | ae2be4dca0d05563883284a8ef72fb23 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an Amazon SQS queue named after the input variable, appending `.fifo` if it’s a FIFO queue, with configurable message size, visibility timeout, retention, and receive wait time, plus a dead-letter queue named with a `-dlq` suffix that receives messages after a configurable number of failed deliveries, and ensure... | resource "aws_sqs_queue" "main" {
name = format("%s%s", var.name, var.fifo ? ".fifo" : "")
max_message_size = var.max_message_size
visibility_timeout_seconds = var.visibility_timeout
message_retention_seconds = var.expiration_time_seconds
receive_wait_time_seco... | production-ready-toolkit/aws-sre-sqs | MIT | sqs.tf | aws | [
"aws_sqs_queue"
] | a739be1d76e00c0ba3a1b0cfe09526cf |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an RDS database instance for each entry in the `var.rds` variable, using the specified engine, version, instance class, allocated storage, and database name, with credentials pulled from AWS Secrets Manager, backed by a dedicated subnet group using the private subnets, a custom parameter group matching the engin... | resource "aws_db_subnet_group" "rds_sg" {
for_each = var.rds
name = each.value.subnet_group_name
subnet_ids = var.private_subnet_ids
tags = merge(
var.common_tags,
{
Name = each.value.subnet_group_name
}
)
}
### RDS Parameter Group ###
resource "aws_db_parameter_group" "rds... | jagadamma/pocistrength | Apache-2.0 | modules/rds/rds.tf | aws | [
"aws_db_instance",
"aws_db_parameter_group",
"aws_db_subnet_group"
] | 57fa176721da958010823b797096a8ad |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EMR instance fleet attached to a specific cluster, with a name, and exact numbers for on-demand and spot instance capacity targets; define one or more instance type configurations, each specifying an EC2 instance type, optional spot bid price (either absolute or as a percentage of on-demand price), and weight... | resource "aws_emr_instance_fleet" "this" {
cluster_id = var.cluster_id
name = var.name
target_on_demand_capacity = var.target_on_demand_capacity
target_spot_capacity = var.target_spot_capacity
dynamic "instance_type_configs" {
for_each = var.instance_type_configs
... | ebogdum/terraform-providers | MIT | aws/resources/emr_instance_fleet/main.tf | aws | [
"aws_emr_instance_fleet"
] | 4e7b525cde37aaff8017949ed522ff01 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC in the ap-south-1b Availability Zone with a configurable CIDR block, attach an internet gateway, provision a number of subnets equal to the length of a provided CIDR list each in ap-south-1b with sequential names like terrasub-1, terrasub-2, etc., associate all subnets with a single route table that routes... | resource "aws_vpc" "myvpc" {
cidr_block = var.vpc_cidr
tags = {
Name = var.vpc_name
}
}
resource "aws_internet_gateway" "mygw" {
vpc_id = aws_vpc.myvpc.id
tags = {
Name = var.gw_name
}
}
resource "aws_subnet" "mysn" {
count = length(var.cidrs)
vpc_id = aws_vpc.myvpc.id
cidr_block = element(... | YashIndane/terraform-scripts | MIT | vpc/vpc.tf | aws | [
"aws_instance",
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 7b8debf851a0f02466f9205c9a8dd19c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM policy named “notebooks-service-secrets-access-policy” that allows the notebooks service to retrieve parameters from Systems Manager Parameter Store and secret values from Secrets Manager, specifically for the secret identified by the variable `secrets_arn`. | resource "aws_iam_policy" "secrets_access" {
name = "notebooks-service-secrets-access-policy"
description = "Policy that gives access to the notebooks-service secrets"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:GetParameters",... | openbraininstitute/aws-terraform-deployment | Apache-2.0 | notebook_service/secret.tf | aws | [
"aws_iam_policy"
] | ad592ecb386dd4e13eab1b8b4d3972e9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.