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 a security group named “web-sg” in the main VPC that allows inbound SSH (port 22) and HTTP (port 80) traffic from anywhere, and permits all outbound traffic; deploy a public subnet named “sre-public-subnet-1” in availability zone us-east-1a with CIDR 10.0.1.0/24 that automatically assigns public IP addresses and...
# creating security group resource "aws_security_group" "web_sg" { name = "web-sg" description = "Allow SSH and HTTP" vpc_id = aws_vpc.main.id # inbound rules (allow SSH access from anywhere) ingress { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0...
derekr06/Cloud-Native-SRE-Platform
MIT
terraform/ec2.tf
aws
[ "aws_instance", "aws_route_table_association", "aws_security_group", "aws_subnet" ]
39448af3da13241de183102df7aeaa79
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named after the short project name in the selected VPC that allows inbound TCP traffic on port 5432 from any IP address and all outbound traffic to any destination, and create a database subnet group named after the short project name using the two public subnets in the us-east-2b and us-east-2c...
# Get existing VPC by name tag data "aws_vpc" "selected" { filter { name = "tag:Name" values = [var.vpc_name] } } # Data sources to get subnets in us-east-2c and us-east-2b data "aws_subnet" "az_c" { filter { name = "vpc-id" values = [data.aws_vpc.selected.id] } filter { name = "ava...
ogbrown/ogb-aurora-tf-proj
MIT
modules/net/main.tf
aws
[ "aws_db_subnet_group", "aws_security_group" ]
8eb5510959efd15b61234b6fe220d41b
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named “terraform-firewall” in us-east-1 with a description “Managed from Terraform”, then add three TCP ingress rules to it: one allowing traffic on the application port, one on the SSH port, and one on the FTP port—each restricted to the IP range specified by the `vpn_ip` variable.
provider "aws" { region = "us-east-1" } resource "aws_security_group" "allow_tls" { name = "terraform-firewall" description = "Managed from Terraform" } resource "aws_vpc_security_group_ingress_rule" "app_port" { security_group_id = aws_security_group.allow_tls.id cidr_ipv4 = var.vpn_ip fro...
viswa2/DevOps
Apache-2.0
terraform/terraform-associate-2024/variables/main.tf
aws
[ "aws_security_group", "aws_vpc_security_group_ingress_rule" ]
8714c2728d957fb32e40f19f77551045
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a CloudWatch metric filter named “UsersServiceErrorFilter” that scans the “users_service_logs” log group for entries containing the word “ERROR” and emits a metric named “UsersServiceErrors” in the “Selena” namespace with a value of 1 for each match. Then create a CloudWatch alarm named “UsersServiceErrorsAlarm”...
resource "aws_cloudwatch_log_metric_filter" "users_service_errors" { name = "UsersServiceErrorFilter" log_group_name = aws_cloudwatch_log_group.users_service_logs.name pattern = "ERROR" metric_transformation { name = "UsersServiceErrors" namespace = "Selena" value = "1" ...
vitalii-q/selena-cloud-infra
MIT
terraform/modules/cloudwatch/log_metric.tf
aws
[ "aws_cloudwatch_log_metric_filter", "aws_cloudwatch_metric_alarm" ]
bf4151d42cd898117d097b2b8fc92223
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create three sets of subnets within the specified VPC: public subnets that automatically assign public IP addresses to instances launched in them, private subnets that do not, and a separate set of secondary private subnets also without public IP assignment—each set configured with CIDR blocks, availability zones, and ...
# ------------------------------------------------------------# # # Subnet # # ------------------------------------------------------------# # Public Subnet resource "aws_subnet" "public" { count = length(var.public_subnets) vpc_id = aws_vpc.this.id map_public_ip_on_launch = true cidr_block ...
page-o/terraform-aws-network
MIT
subnet.tf
aws
[ "aws_subnet" ]
0a2c901206c1e1dd2ba732ed3717f2e4
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a DynamoDB table named via the `dynamodb_table_name` variable with on-demand billing, using `id` as the primary key, and add five attributes: `id`, `email`, `status_upload`, `url_download`, and `data_criacao`, all as strings. Add four global secondary indexes—one each for `email`, `url_download`, `status_upload`...
resource "aws_dynamodb_table" "uploads" { name = var.dynamodb_table_name billing_mode = "PAY_PER_REQUEST" hash_key = "id" attribute { name = "id" type = "S" } attribute { name = "email" type = "S" } attribute { name = "status_upload" type = "S" } attribute { ...
fiap-8soat-tc-one/hackathon-fiap-iac
MIT
src/modules/3-dynamodb/resources.tf
aws
[ "aws_dynamodb_table", "aws_iam_policy" ]
d3198360f55aa0d05c2c3611d48476ca
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Kubernetes ServiceAccount named `aws-load-balancer-controller` in the `kube-system` namespace, annotated with the IAM role ARN for IRSA, and label it for identification and management by Terraform; then install the AWS Load Balancer Controller Helm chart version specified by `var.alb_controller_version` from t...
# Kubernetes ServiceAccount for AWS Load Balancer Controller # Uses IRSA (IAM Roles for Service Accounts) - IAM role is in iam.tf resource "kubernetes_service_account" "alb_controller" { metadata { name = "aws-load-balancer-controller" namespace = "kube-system" annotations = { "eks.amazonaws.co...
EKS-CLuster-Full-Feature-TF/EKS-CLuster-Full-Feature-TF
MIT
modules/alb-controller/kubernetes.tf
k8s
[ "helm_release", "kubernetes_service_account" ]
d6441a387e1525e52295b16842e343f0
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an ECS cluster named by combining the resource name prefix and Selenium cluster name, enable Container Insights, configure it to use FARGATE as the sole capacity provider with a default strategy that routes 100% of tasks to FARGATE, and set up an HTTP service discovery namespace using the provided DNS name for S...
locals { cluster_name_prefix = join("-", [var.resource_name_prefix, var.selenium_cluster_name]) } resource "aws_ecs_cluster" "selenium_grid" { name = local.cluster_name_prefix service_connect_defaults { namespace = aws_service_discovery_http_namespace.selenium.arn } setting { name = "containerInsight...
Mohan0607/selenium-infra-terraform
MIT
Infrastructure-terraform/modules/ecs_cluster/main.tf
aws
[ "aws_ecs_cluster", "aws_ecs_cluster_capacity_providers", "aws_service_discovery_http_namespace" ]
39d971368b10277aa66ca2550b652878
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an SQS queue with outputs for its ARN and URL, optionally create a dead-letter queue when enabled, and store all four ARN/URL values in SSM Parameter Store under the path `/project/environment/name/central/sqs/` with keys `sqs_arn`, `sqs_url`, `dlq_sqs_arn`, and `dlq_sqs_url`.
output "sqs_arn" { value = aws_sqs_queue.main.arn } output "sqs_url" { value = aws_sqs_queue.main.url } output "dlq_sqs_arn" { value = var.enable_dlq == true ? aws_sqs_queue.dlq[0].arn : null } output "dlq_sqs_url" { value = var.enable_dlq == true ? aws_sqs_queue.dlq[0].url : null } resource "aws_ssm_parame...
opstimus/terraform-aws-sqs
Apache-2.0
outputs.tf
aws
[ "aws_ssm_parameter" ]
618a9dbd499f3582dc661c514cf6d9d6
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create three Gateway VPC endpoints for Amazon S3, one for each of the three private route tables in the default VPC, using a permissive IAM policy that allows all principals to access all S3 resources, and tag each with a name including the current workspace. Also create interface VPC endpoints for ECR API, ECR DKR, Cl...
resource "aws_vpc_endpoint" "s3" { count = 3 vpc_id = aws_default_vpc.default.id service_name = "com.amazonaws.${data.aws_region.current.name}.s3" route_table_ids = [aws_route_table.private[count.index].id] vpc_endpoint_type = "Gateway" policy = data.aws_iam_policy_d...
ministryofjustice/opg-shared-infrastructure
MIT
vpc_endpoints.tf
aws
[ "aws_security_group", "aws_security_group_rule", "aws_vpc_endpoint" ]
2b60964bffc6fec901efa7395f649c97
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create three standard SNS topics named according to variables for budget limit exceeded alerts, API Gateway route throttling events, and notification message sending, each configured with Lambda success and failure feedback using the same IAM role and a configurable success sample rate, with X-Ray tracing explicitly di...
resource "aws_sns_topic" "budget_limit_exceeded_action" { name = var.sns_topic_budget_limit_exceeded_name lambda_success_feedback_role_arn = aws_iam_role.sns_cloudwatch_feedback_role.arn lambda_success_feedback_sample_rate = var.lambda_success_sample_rate lambda_failure_feedback_ro...
fiscalismia/fiscalismia-infrastructure
MIT
terraform/aws/modules/sns_topic/sns.topics.tf
aws
[ "aws_sns_topic" ]
7d21871993c309d0f0f5c113c5e6f93e
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named “my_lambda_role” that AWS Lambda can assume, attach to it a policy named “my_lambda_policy” granting full access to EC2, Elastic Load Balancing, CloudWatch, and Auto Scaling services—including permission to create service-linked roles only for specific AWS services—and log write access to the L...
data "aws_iam_policy_document" "assume_role_policy" { statement { actions = ["sts:AssumeRole"] principals { type = "Service" identifiers = ["lambda.amazonaws.com"] } } } data "aws_iam_policy_document" "lambda_custom_policy" { statement { sid = "" effect = "Allow" ...
aws-samples/autoscalinggroup-plus-secondary-eni
MIT-0
modules/lambda/main.tf
aws
[ "aws_autoscaling_lifecycle_hook", "aws_cloudwatch_event_rule", "aws_cloudwatch_event_target", "aws_cloudwatch_log_group", "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment", "aws_lambda_function", "aws_lambda_permission" ]
e4c26b3c0b44b8c54dffaa80b5710423
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a VPC named “seunghyun-vpc” in the ap-northeast-2 region with a 10.10.0.0/16 CIDR block, DNS support and hostnames enabled. Add two subnets named “seunghyun-subnet1” and “seunghyun-subnet2” in the first available availability zone with CIDR blocks 10.10.100.0/24 and 10.10.101.0/24 respectively, and associate bot...
provider "aws" { region = "ap-northeast-2" } data "aws_availability_zones" "available" { state = "available" } resource "aws_vpc" "myvpc" { cidr_block = "10.10.0.0/16" enable_dns_support = true enable_dns_hostnames = true tags = { Name = "seunghyun-vpc" } } resource "aws_subnet" "seung...
limseunghyun95/T102-Terraform
MIT
week02-assignment/02-custom-aws-resource/vpc.tf
aws
[ "aws_internet_gateway", "aws_route", "aws_route_table", "aws_route_table_association", "aws_subnet", "aws_vpc" ]
a805f71eea29b6a53e6015708a9bee41
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a network load balancer named with the environment, project, and node ID that listens on TCP/UDP port 30303, forwards traffic to a target group on the same port, and associate it with a Route 53 A record pointing to the load balancer’s DNS name using health-checked aliasing. Provision an EC2 Auto Scaling group w...
data "aws_ami" "ubuntu" { most_recent = true // http://cloud-images.ubuntu.com/locator/ec2/ // https://www.kisphp.com/terraform/terraform-find-ubuntu-and-amazon-linux-2-amis filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-*-20.04-amd64-server-*"] } filter { name = "virtualiz...
nhancv/nchain.poa
MIT
network_core/modules/compute_node/main.tf
aws
[ "aws_autoscaling_group", "aws_iam_instance_profile", "aws_iam_role", "aws_iam_role_policy", "aws_launch_template", "aws_lb", "aws_lb_listener", "aws_lb_target_group", "aws_route53_record" ]
98ba71c54d4209aa0fbffdd70fad1d8f
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a public-facing Application Load Balancer named with the value of the `name` variable suffixed by `-alb`, configured to listen on HTTP port 80 and forward traffic to a target group named with the `name` variable suffixed by `-tg-frontend` on port 80 using HTTP, with a health check on path `/` expecting a 200 sta...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } resource "aws_security_group" "alb" { name = "${var.name}-alb-sg" description = "ALB SG" vpc_id = var.vpc_id ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0...
Doughscloud/aws-fargate-tech-challenge
Apache-2.0
infra/modules/alb/main.tf
aws
[ "aws_lb", "aws_lb_listener", "aws_lb_target_group", "aws_security_group" ]
fb3c46092c2006c4d51df4193b386980
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 with the project name suffixed by “-on-demand” that spans three specific private subnets, with capacity settings defined by variables, using the latest version of a pre-defined launch template, and tagging instances with both a Name tag and an AmazonECSManaged tag that propagate at la...
resource "aws_autoscaling_group" "on_demand" { name_prefix = format("%s-on-demand-", var.project_name) vpc_zone_identifier = [ data.aws_ssm_parameter.subnet_private_1a.value, data.aws_ssm_parameter.subnet_private_1b.value, data.aws_ssm_parameter.subnet_private_1c.value ] desired_capacity = var.clus...
srportto/linuxtips-curso-containers-ecs-cluster
MIT
asg.tf
aws
[ "aws_autoscaling_group", "aws_ecs_capacity_provider" ]
911c9595b3bf7cee2340c34c788932f8
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a private S3 bucket with versioning enabled and protection against accidental deletion, and provision a DynamoDB table named with the provided table name variable that uses LockID as its sole partition key with on-demand billing.
resource "aws_s3_bucket" "this" { bucket = var.bucket_name acl = "private" versioning { enabled = true } lifecycle { prevent_destroy = true } } resource "aws_dynamodb_table" "this" { name = var.table_name hash_key = "LockID" billing_mode = "PAY_PER_REQUEST" attribute { ...
tbekas/aws-organization-example
MIT
modules/backend/main.tf
aws
[ "aws_dynamodb_table", "aws_s3_bucket" ]
db7b1158031edda93079ec79a08da880
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named “Jenkins-Security-Group” that allows inbound SSH on port 22, HTTP on port 80, and Jenkins web UI traffic on port 8080 from any IP address, and permit all outbound traffic; then launch a t2.micro EC2 instance in us-east-1 using AMI ami-06640050dc3f556bb, assign it the security group, attach...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { region = "us-east-1" } resource "aws_security_group" "Jenkins-Security-Group" { name = "Jenkins-Security-Group" } resource "aws_security_group_rule" "allow_22_TLS_inbound" { type = "ingres...
spiffaz/Devops
MIT
CI-CD/4/main.tf
aws
[ "aws_instance", "aws_security_group", "aws_security_group_rule" ]
d502d89be48917a67cdea11cb274ae9b
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named using the project name and environment with access logs prefix, force-destroy it on deletion, set ownership to bucket-owner preferred, apply the ACL specified by the log_bucket_acl variable, enable AES256 server-side encryption, block all public access including ACLs, policies, and bucket rest...
resource "aws_s3_bucket" "s3_access_logs_bucket" { bucket_prefix = var.access_log_bucket_prefix == "" ? lower(substr(replace("fd-${var.project_name}-${var.environment}-access-logs-", "_", "-"), 0, 63)) : var.access_log_bucket_prefix force_destroy = true } resource "aws_s3_bucket_ownership_controls" "s3_access_logs...
KayakinCoder/filmdrop-learn
Apache-2.0
modules/base_infra/log_archive/s3_access_logs.tf
aws
[ "aws_s3_bucket", "aws_s3_bucket_acl", "aws_s3_bucket_ownership_controls", "aws_s3_bucket_public_access_block", "aws_s3_bucket_server_side_encryption_configuration", "null_resource" ]
e31d4a22d05b31ef22189ea5458e062d
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Allocate one Elastic IP per availability zone for NAT Gateways, tagged with the organization, application, and environment names plus the zone identifier, and allocate additional Elastic IPs bound directly to each public network interface created elsewhere in the configuration.
# Elastic IPs for NAT Gateways resource "aws_eip" "nat" { for_each = var.availability_zones domain = "vpc" tags = { Name = "${var.org}-${var.app}-${var.env}-nat-eip-${each.key}" } } resource "aws_eip" "public_nic" { for_each = aws_network_interface.public domain =...
AzySir/terraform-aws-vpc
MIT
eip.tf
aws
[ "aws_eip" ]
f82dd175f31baf510701f1c3f29e1faf
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 bucket policy that enforces server-side encryption using either AES256 or a specific KMS key (if provided), blocks any public read or write ACLs and grants, denies non-SSL access to objects, and optionally grants log-delivery write permissions to the logging service.
locals { disallowed_encryptions = toset(concat( tolist(var.disallowed_encryptions), [""], local.encryption == "aws:kms" && var.kms_key_arn != null ? ["AES256"] : [] )) } data "aws_iam_policy_document" "standard" { count = var.override_policy_json == null ? 1 : 0 dynamic "statement" { for_each = ...
NHSDigital/terraform-aws-odin-common
MIT
modules/s3-bucket/policy.tf
aws
[ "aws_s3_bucket_policy" ]
0e5fb6477db0baecb027e05b17d620df
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 “aurora-cluster-demo” in the sa-east-1 region with engine version 8.0.mysql_aurora.3.02.0, database name “mydb”, a five-day backup retention, daily backups between 07:00 and 09:00, and no final snapshot on deletion; provision exactly one cluster instance named “aurora-cluster-demo-0...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { # region = "us-east-2" # Just for fun... Sa~o Paulo region = "sa-east-1" } variable "rds_username" { description = "The username for the RDS DB main user" type = string sensitive = true ...
reed9999/terraform-excuses-to-use
Apache-2.0
benchmark-emr-vs-db/main-benchmark.tf
aws
[ "aws_rds_cluster", "aws_rds_cluster_instance" ]
f94e7dc882b457ad0d0a21fae2341734
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a KMS key named “aws-waf-logs-ctf-key” with multi-region support and automatic key rotation, configured so that the account root and the CloudWatch Logs service in the current region can use it to encrypt and decrypt log data specifically for WAF log groups matching the pattern “aws-waf-logs-*”; alias the key as...
data "aws_caller_identity" "current" {} data "aws_region" "current" {} # # Based on AWS documentation: Encrypt log data in CloudWatch Logs using AWS Key Management Service # https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html # data "aws_iam_policy_document" "cloudwatch_waf_kms" { state...
rewindio/trust-ctf
MIT
cloudwatch.tf
aws
[ "aws_cloudwatch_log_group", "aws_cloudwatch_query_definition", "aws_kms_alias", "aws_kms_key" ]
8240080e4ba749fa3d23b520fb8e1bb7
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named using the `bucket-name` variable, ensure it cannot be accidentally deleted, and enable versioning on it using the `status` variable to control whether versioning is enabled or suspended.
resource "aws_s3_bucket" "tf-state" { bucket = var.bucket-name lifecycle { prevent_destroy = true } } resource "aws_s3_bucket_versioning" "name" { bucket = aws_s3_bucket.tf-state.id versioning_configuration { status = var.status } }
MahmoudSamir0/3-tier-application-deployment
MIT
all-modules/s3/main.tf
aws
[ "aws_s3_bucket", "aws_s3_bucket_versioning" ]
4910b8ed325c6e2181ba59f21a2f33d2
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a single-node Redis cluster named “lgr-redis-cluster” using engine version 7.0 and a cache.t4g.micro node type, deployed in three private subnets via a subnet group named “redis-subnet-group”, with security group “redis-security-group” allowing only ingress on port 6379 from the auth ECS task security group, no ...
resource "aws_elasticache_subnet_group" "redis_subnet_group" { name = "redis-subnet-group" subnet_ids = [ aws_subnet.private_1.id, aws_subnet.private_2.id, aws_subnet.private_3.id ] tags = { Name = "redis-subnet-group" Project = var.project Owner = var.owner } } resource "aws_se...
kenesparta/lgrb-tf
MIT
elastic-cache.tf
aws
[ "aws_elasticache_replication_group", "aws_elasticache_subnet_group", "aws_security_group", "aws_security_group_rule", "aws_ssm_parameter" ]
9f32e1a3a6a0fc932265b6f13a3ae7f4
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create three security groups in the specified VPC: one for the database named using the namespace and project name with “-db” suffix, allowing all outbound traffic but no inbound rules; one for the ALB named with “-alb” suffix, allowing HTTPS inbound only from CloudFront IP prefixes and all outbound traffic; and one fo...
resource "aws_security_group" "database" { name = "${var.namespace}-${var.project_name}-db" vpc_id = var.vpc_id egress { description = "Allow all outbound traffic" from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } # ingress { # description =...
giammbo/iac-template
MIT
terraform/ecs_postgress/sg.tf
aws
[ "aws_security_group" ]
5341205c6e6d7f9c49d81c0cd94fcb07
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create one ECS task definition per service defined in `var.services`, naming each using the pattern `<environment>-<project>-<service>` and configuring it to run in `awsvpc` network mode with a single essential container that uses the specified image, exposes the given target port on both container and host, and sends ...
resource "aws_ecs_task_definition" "tasks" { for_each = var.services family = "${var.general.environment}-${var.general.project}-${each.key}" network_mode = "awsvpc" container_definitions = jsonencode([{ name = each.key, image = each.value.img , essential = true, portMappings = [ ...
NazarSenchuk/awsecs
MIT
modules/ecs/tasks.tf
aws
[ "aws_ecs_task_definition" ]
3400db84dd485a05bf809ad5e8e4d968
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a traffic mirror filter named “VirtualNetworkSensor-TrafficMirrorFilter” that mirrors all inbound and outbound traffic (both IPv4 and IPv6) to two network interfaces: one private and one public, designated as the data port targets for a Virtual Network Sensor instance.
# ############################################################################# # Traffic Mirror # ############################################################################# # https://docs.trendmicro.com/en-us/documentation/article/trend-vision-one-network-sensor-traffic-mirror resource "aws_ec2_traffic_mirror_filte...
mawinkler/playground-one
MIT
awsone/2-network/vns-va/traffic.tf
aws
[ "aws_ec2_traffic_mirror_filter", "aws_ec2_traffic_mirror_filter_rule", "aws_ec2_traffic_mirror_target" ]
533a82a4a69faee81339f28ec731a1ff
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Add a member to an existing Detective investigation graph in the specified region, using the provided AWS account ID and email address, include the custom invitation message, and suppress the automatic email notification to the invitee.
resource "aws_detective_member" "this" { region = var.region account_id = var.account_id email_address = var.email_address graph_arn = var.graph_arn message = var.message disable_email_notification = var.disable_email_notif...
ebogdum/terraform-providers
MIT
aws/resources/detective_member/main.tf
aws
[ "aws_detective_member" ]
713d197650f9356350c683eb9de21356
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a number of client virtual machines in the us-east-2a availability zone, each using a specified AMI, instance type, and public subnet, with a public IP assigned and an encrypted root EBS volume sized and typed per configuration, all launched with the same SSH key and tagged with environment, project, setup na...
resource "aws_instance" "client" { count = var.client_instance_count ami = var.client_instance_ami instance_type = var.client_instance_type subnet_id = data.terraform_remote_state.shared_resources.outputs.subnet_public_id vpc_secur...
redis-performance/testing-infrastructure
Apache-2.0
terraform/re-1node-scale1-c6i.2xlarge/bench-client-resources.tf
aws
[ "aws_instance" ]
b73db2c8a5a3769a90ce46ef85d5ba04
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 HTTP and HTTPS traffic from anywhere (both IPv4 and IPv6), and permits all outbound traffic. Also create a second security group for ECS tasks that allows inbound traffic on the container port from anywhere (both IPv4 and IPv6), and also permi...
resource "aws_security_group" "alb" { name = "${var.name}-sg-alb" vpc_id = var.vpc_id ingress { protocol = "tcp" from_port = 80 to_port = 80 cidr_blocks = ["0.0.0.0/0"] ipv6_cidr_blocks = ["::/0"] } ingress { protocol = "tcp" from_port ...
av-ast/tf-study-infra
Apache-2.0
modules/security_groups/main.tf
aws
[ "aws_security_group" ]
a33f3ef5c0e1284a1f6589cedbb1658a
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named “ec2-jump” that EC2 instances can assume using the trust policy in `./policy/assume_role_ec2_jump.json`, attach a policy named “ec2-jump” with permissions for debugging and SSH access defined in `./policy/ec2_jump.json`, and create an instance profile named “ec2-jump” to allow EC2 instances to ...
resource "aws_iam_role" "ec2_jump" { name = "ec2-jump" assume_role_policy = file("./policy/assume_role_ec2_jump.json") } resource "aws_iam_policy" "ec2_jump" { name = "ec2-jump" description = "give jump ec2 basic rights for debugging and ssh" policy = file("./policy/ec2_jump.json") ...
steel-pinion/unreal-helix
MIT
infra/dependencies/role.tf
aws
[ "aws_iam_instance_profile", "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
d079b80f1b4f85a261f478efbd3650e9
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a launch template named after the component and environment variables, using the latest AMI from a data source, configured to launch Spot Instances of a one-time type with a specific instance type, attached to a designated security group, tagged with a Name matching the component and environment, and initialized...
resource "aws_launch_template" "launch-template" { name = "${var.COMPONENT}-${var.ENV}" image_id = data.aws_ami.ami.id instance_market_options { market_type = "spot" spot_options { spot_instance_type = "one-time" } } instance_type = var.INSTANCE_TYPE vpc_security_group_ids = ...
hansikvarun/terraform-immutable-app-module
Apache-2.0
launch-template.tf
aws
[ "aws_launch_template" ]
9bafdd7fea30346adaf0b1ae58a57694
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM policy named “terragrunt-sample-policy” that allows any S3 read action (like GetObject, GetBucketLocation, etc.) on all S3 resources, and attach it to the IAM role specified by the `iam_role_name` variable.
data "aws_iam_policy_document" "sample_policy" { statement { effect = "Allow" actions = [ "s3:Get*", ] resources = ["*"] } } resource "aws_iam_policy" "sample_policy" { name = "terragrunt-sample-policy" policy = data.aws_iam_policy_document.sample_policy.json } resource "aws_iam_role_p...
the-exile-110/terragrunt-demo
MIT
envs/stg/iam_policy/main.tf
aws
[ "aws_iam_policy", "aws_iam_role_policy_attachment" ]
5aabfeae6261468c96833ce85efa37f0
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a MemoryDB cluster with configurable settings including ACL association, node type, region, and auto minor version upgrades; specify the number of shards and replicas per shard, enable or disable TLS, define maintenance windows and snapshot policies, and allow custom timeouts for create, update, and delete opera...
resource "aws_memorydb_cluster" "this" { acl_name = var.acl_name node_type = var.node_type region = var.region auto_minor_version_upgrade = var.auto_minor_version_upgrade data_tiering = var.data_tiering description = var.des...
ebogdum/terraform-providers
MIT
aws/resources/memorydb_cluster/main.tf
aws
[ "aws_memorydb_cluster" ]
98fa89c93b90d1d486016899a98a1d6f
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named with the environment prefix followed by “-sg” in the specified VPC, allowing inbound SSH (port 22), HTTP (port 80), HTTPS (port 443), WireGuard VPN traffic (UDP port 51820), and a WireGuard configuration server (TCP port 8080) from any IP address, plus all outbound traffic.
# Security Group for the instance resource "aws_security_group" "main" { name_prefix = "${var.environment}-sg" vpc_id = var.vpc_id description = "Security group for instance with ports 22, 80, 443 and 51820" # SSH (Port 22) ingress { description = "SSH" from_port = 22 to_port = 22 ...
cflarios/terraform-aws-vpn
MIT
terraform/modules/security_group/main.tf
aws
[ "aws_security_group" ]
a0c5e95c646b02564879b5dd4752e5d1
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named either from the `report_bucket_name` variable or derived from the `prefix` variable, the current AWS region, and the suffix `-cur-reports`, with versioning enabled, all public access blocked, ownership controls enforced to prevent accidental overwrites, and server-side encryption using a KMS k...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } data "aws_billing_service_account" "current" {} data "aws_caller_identity" "current" {} data "aws_region" "current" {} # s3 bucket resource "aws_s3_bucket" "cost_and_usage" { bucket = var.report_bucket_name != "" ? var.repo...
fortunecookiezen/aws-tf-cur-bucket
Apache-2.0
main.tf
aws
[ "aws_kms_key", "aws_s3_bucket", "aws_s3_bucket_ownership_controls", "aws_s3_bucket_policy", "aws_s3_bucket_public_access_block", "aws_s3_bucket_server_side_encryption_configuration", "aws_s3_bucket_versioning" ]
5b60ab294a9c8b289febaf6edc81b111
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM instance profile named `local.name` with an associated role that allows EC2 instances to assume it, attach the three AWS managed policies for ECS task execution, EC2 container service, and SSM management, and only provision these resources if `local.enabled` is true.
locals { policies_to_attach = toset([ "service-role/AmazonECSTaskExecutionRolePolicy", "service-role/AmazonEC2ContainerServiceforEC2Role", "AmazonSSMManagedInstanceCore" ]) } resource "aws_iam_instance_profile" "default" { count = local.enabled ? 1 : 0 name = local.name role = local.name } dat...
pedropinheiro75/terraform-aws-ecs-cluster
MIT
iam.tf
aws
[ "aws_iam_instance_profile", "aws_iam_role", "aws_iam_role_policy_attachment" ]
3f7e9cd1b357f936d8413070bebf605f
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an AWS Load Balancer Controller in the kube-system namespace with a service account annotated to assume the ALB controller IAM role, then deploy the controller via Helm using the eks-charts repository, passing in the EKS cluster name, service account name, AWS region, VPC ID, and two subnet IDs. Set up an intern...
resource "kubernetes_service_account_v1" "alb_controller" { metadata { name = "aws-load-balancer-controller" namespace = "kube-system" annotations = { "eks.amazonaws.com/role-arn" = aws_iam_role.alb_controller.arn } } } resource "helm_release" "alb_controller" { depends_on = [ aws...
Falltrades/cloud-example
MIT
static-website/aws-eks/terraform/kubernetes.tf
k8s
[ "helm_release", "kubernetes_deployment_v1", "kubernetes_ingress_v1", "kubernetes_service_account_v1", "kubernetes_service_v1" ]
aa6f8b0e11d88e8bea2090a071e2f32a
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 specified in `var.vpc_cidr` only if no existing VPC matches that CIDR; otherwise, use the existing VPC. Then create a single private subnet in that VPC with the CIDR block from `var.private_subnet_1_cidr` and in the availability zone specified by `var.availability_zone_1`.
# 🔍 Buscar VPC existente por CIDR data "aws_vpc" "existing_vpc" { filter { name = "cidr-block" values = [var.vpc_cidr] } } # 🏗️ Crear VPC solo si NO existe resource "aws_vpc" "this" { count = length(data.aws_vpc.existing_vpc.id) > 0 ? 0 : 1 cidr_block = var.vpc_cidr } # 🔹 Crear Subnet en VPC...
adgsgutierrez/dinners-infraestructure-aws
MIT
modules/vpc/main.tf
aws
[ "aws_subnet", "aws_vpc" ]
5ec2ced8f41525f04c9ac387eef77815
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an OpenID Connect provider pointing to the SPIRE bundle S3 bucket in the specified region, with the standard AWS STS client ID and a fixed thumbprint, then define workload IAM roles named after the cluster and workload keys (with underscores replaced by hyphens) that trust the SPIRE OIDC provider and restrict ac...
resource "aws_iam_openid_connect_provider" "spire" { url = "https://${var.spire_bundle_s3_bucket}.s3.${var.region}.amazonaws.com" client_id_list = [ "sts.amazonaws.com" ] thumbprint_list = ["9e99a48a9960b14926bb7f3b02e22da2b0ab7280"] tags = var.tags } resource "aws_iam_role" "workload" { for_each = ...
fengyu225/db-iam-auth
Apache-2.0
aws/modules/iam/main.tf
aws
[ "aws_iam_openid_connect_provider", "aws_iam_role", "aws_iam_role_policy" ]
63b427957cda885204b5496fe455be6c
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a mock AWS environment in us-west-2 with a single VPC of CIDR 10.0.0.0/16 named “test-vpc”, two subnets—10.0.1.0/24 in us-west-2a named “test-subnet-1” and 10.0.2.0/24 in us-west-2b named “test-subnet-2”—within that VPC, an EKS cluster named “test-eks-cluster” using those two subnets and an IAM role named “test-...
# Mock module for testing # This file is used to mock the AWS resources for testing purposes # Mock AWS provider provider "aws" { region = "us-west-2" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true access_key = "m...
xCodeMuse/eks-terraform
Apache-2.0
modules/eks-managed-node-group/tests/mock_module.tf
aws
[ "aws_eks_cluster", "aws_iam_role", "aws_security_group", "aws_subnet", "aws_vpc" ]
c24a357391f88662a57debc722a032a0
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision an EC2 instance named “Hello world” in the specified availability zone using the given AMI and instance type, attach it to the webserver security group, assign it the “terraform” SSH key pair, link it to the EC2 instance profile for IAM role access, and run a user data script that updates the system, installs...
resource "aws_instance" "hello-world" { ami = "${var.ami}" instance_type = "${var.instance_type}" vpc_security_group_ids = ["${aws_security_group.webserver_sg.id}"] availability_zone = "${var.az}" key_name = "terraform" iam_instance_profile = "${aws_iam_insta...
hariyopmail/DevOps
Apache-2.0
terraform/AWS_Terraform/Section-07-working-with-iam-role-policy/webserver.tf
aws
[ "aws_instance" ]
c99e6e929f25b486ff022fed89af64d8
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an HTTP load balancer target group named using the `target_group_name` variable, listening on the port specified by `port_for_lb_target_group`, using IP targets in the VPC identified by `vpc_for_lb_target_group`, with health checks enabled every 300 seconds, requiring two consecutive successful or 200/404 respon...
resource "aws_lb_target_group" "provider_alb_target_group" { name = var.target_group_name port = var.port_for_lb_target_group protocol = "HTTP" target_type = "ip" vpc_id = var.vpc_for_lb_target_group health_check { enabled = true healthy_threshold = 2 interval = 300 pr...
haarshdev/terraform-with-AWS
MIT
terraform/modules/init/alb/provider-alb-target-group/main.tf
aws
[ "aws_lb_listener", "aws_lb_target_group" ]
16fb81fdc189a8f7c70fcd7d07cdc23a
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named with the environment variable `my-env` suffixed by `-terraform-bucket-sritesh-1234`, and tag it with both a `Name` tag matching the bucket name and an `environment` tag set to the value of `my-env`.
# S3 Bucket # Resource Block resource "aws_s3_bucket" "my-bucket" { bucket = "${var.my-env}-terraform-bucket-sritesh-1234" # Change to a unique name tags = { Name = "${var.my-env}-terraform-bucket-sritesh-1234" environment = var.my-env } }
SriteshSuranjan/Multi-Env-AWS-Infra-with-Terraform
MIT
aws_infra/my_bucket.tf
aws
[ "aws_s3_bucket" ]
f0d3e7f1f5766a8df1f2f3458ea569b3
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named “tktk-service-website” configured as a public static website with “index.html” as the index document, “error.html” as the error document, and a routing rule that redirects requests for paths starting with “src/” to instead use “source/”; ensure the bucket is publicly readable and tag it with “...
# Copyright (c) 2022 Erik Steringer and NCC Group # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, m...
ncc-erik-steringer/Aerides
MIT
infracode/modules/tktk_service_website/main.tf
aws
[ "aws_iam_user", "aws_iam_user_policy", "aws_s3_bucket" ]
cc2da1c3b7e7f1a03f3773d7d1caedab
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a MySQL database instance in RDS with the identifier specified by the variable, using MySQL 8.0, 60 GB maximum allocated storage, 14-day backup retention, and enhanced monitoring enabled only if requested; configure it to use a dedicated DB subnet group built from provided subnets, allow MySQL traffic (port 3306...
resource "aws_db_subnet_group" "default" { name = "${var.identifier}-db-subnet-group" subnet_ids = var.subnet_ids tags = { Name = "${var.identifier} DB subnet group" } } data "aws_security_group" "security_groups" { for_each = toset(var.security_group_names) name = each.value } resource "aw...
opzkit/terraform-aws-rds-instance-mysql
MIT
main.tf
aws
[ "aws_db_instance", "aws_db_parameter_group", "aws_db_subnet_group", "aws_security_group" ]
66d1812d6d353cee67d717e2b6780595
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an Amazon Aurora cluster with a master username and randomly generated password stored in AWS Secrets Manager, and publish the cluster’s primary endpoint, reader endpoint, database name, and optionally the RDS Proxy and RDS Proxy readonly endpoints (if enabled) as SSM Parameters under a structured path including...
output "db_password_secret" { value = aws_secretsmanager_secret.main.name } resource "aws_ssm_parameter" "dns" { name = "/${var.project}/${var.environment}/central/aurora${local.ssm_name}/dns" type = "String" value = aws_rds_cluster.main.endpoint } resource "aws_ssm_parameter" "reader_endpoint" { name = ...
opstimus/terraform-aws-aurora
Apache-2.0
outputs.tf
aws
[ "aws_secretsmanager_secret", "aws_secretsmanager_secret_version", "aws_ssm_parameter" ]
25ef37a7d4718a856fa4ac4631bf267c
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a RabbitMQ broker named “mq” running version 3.13 on an mq.m5.large instance, deployed across multiple Availability Zones in a cluster configuration, with no public access, automatic minor version upgrades enabled, and a single user whose credentials are provided via variables. Configure a security group named “...
resource "aws_mq_broker" "mq" { broker_name = "mq" engine_type = "RabbitMQ" engine_version = "3.13" host_instance_type = "mq.m5.large" security_groups = [aws_security_group.mq_sg.id] deployment_mode = "CLUSTER_MULTI_AZ" subnet_ids ...
Sports-Club-Management-Platform/control-room
MIT
terraform_modules/message_queue/rabbitMQ.tf
aws
[ "aws_mq_broker", "aws_security_group" ]
9c54685a78f994f8d6563c40e9e5c1ed
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a CloudWatch Events rule that triggers on EC2 instance state changes (running, stopped, or terminated), configure it to invoke a Lambda function named with the provided prefix, unique name, and suffix, ensure the Lambda has permission to be invoked by CloudWatch Events, package the Lambda code from the local `fu...
#Event rule to direct events to the Lambda Function resource "aws_cloudwatch_event_rule" "event" { name = "${var.name_prefix}-${var.unique_name}-rule${var.name_suffix}" description = "Pattern of events to forward to targets" event_pattern = <<PATTERN { "source": [ "aws.ec2" ], "detail-type": [ ...
StratusGrid/terraform-aws-lambda-event-handler-cpu-creditbalance
Apache-2.0
config.tf
aws
[ "aws_cloudwatch_event_rule", "aws_cloudwatch_event_target", "aws_cloudwatch_log_group", "aws_iam_role", "aws_iam_role_policy", "aws_kms_key", "aws_lambda_function", "aws_lambda_permission" ]
f02b056a91606966b8975128813e3160
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named using the project and environment variables for an RDS PostgreSQL database, allowing inbound PostgreSQL traffic (port 5432) only from a specific web application security group, while permitting all outbound traffic, and output its ID.
######################################## # RDS Database Security Group (PostgreSQL) ######################################## resource "aws_security_group" "db_sg" { name = "${var.project_name}-${var.environment}-db-sg" description = "Allow PostgreSQL access from WebApp EC2 only" vpc_id = aws_vpc.main...
csye6225-siddheshsawant/tf-aws-infra
MIT
rds_sg.tf
aws
[ "aws_security_group" ]
d260234e70bbb3874189736bd7c8d3f0
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a CloudWatch metric alarm named after the Lambda function with “-error-alarm” appended, configured to trigger when the Lambda’s error count reaches or exceeds 1 over any single 60-second period, and send notifications to the specified SNS topic both when the alarm enters alarm state and when it returns to OK sta...
# Triggers a SNS notification when this lambda exits with an error status. resource "aws_cloudwatch_metric_alarm" "alarm" { alarm_name = "${var.lambda_name}-error-alarm" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = 60 metric_name = "Errors" namespace ...
figtools/figgy
Apache-2.0
terraform/modules/figgy_lambda/alarm.tf
aws
[ "aws_cloudwatch_metric_alarm" ]
128c661e61bacebaf757ba924ec8b640
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a VPC with a public subnet in us-east-1a, attach an internet gateway, configure a route table that routes all traffic (0.0.0.0/0) to the internet gateway, and associate that route table with the subnet. Launch two Amazon Linux EC2 instances named server1 and server2 in that subnet with a t2.micro type, assign th...
# creates a vpc resource "aws_vpc" "my-vpc" { cidr_block = var.vpc-subnet tags = { Name = "my-vpc" } } # creates a subnet resource "aws_subnet" "server1-subnet" { vpc_id = aws_vpc.my-vpc.id cidr_block = var.public-subnet1-id availability_zone = "us-east-1a" tags = { Name = "server1-su...
Pradhyumna789/terraform-aws-ebs-migrator-withinAZ
MIT
main.tf
aws
[ "aws_ebs_volume", "aws_instance", "aws_internet_gateway", "aws_route_table", "aws_route_table_association", "aws_security_group", "aws_subnet", "aws_volume_attachment", "aws_vpc" ]
47e268448fbc6d3d7b5ef88e5459f8f2
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named after the Nexus instance with an SSH rule allowing inbound access only from the VPN client’s private IP, a web rule allowing inbound HTTP traffic on port 8081 from anywhere, and an egress rule permitting all outbound traffic to any destination.
locals { vpn_cidrs = "${var.vpn_private_ip}/32" } resource "aws_security_group" "this" { name = "${local.instance_name}-sg" description = "SG for the Nexus instance" vpc_id = var.vpc_id tags = merge({ Name = "${local.instance_name}-sg" }, local.tags) } resource "aws_security_group_rule" "...
pasdam/terraform-aws-sonatype-nexus
Apache-2.0
security_group.tf
aws
[ "aws_security_group", "aws_security_group_rule" ]
ae15fe38ecae050e5ca4d6ae97278e44
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a regional API Gateway REST API named `<project_name>-<environment>-api` to route traffic for the PetClinic microservices application, with the root path (`/`) proxied to the ALB, `/admin` and its subpaths proxied to `admin-server`, and `/api/customers`, `/api/vets`, and `/api/visits` (and their subpaths) proxie...
# -------------------------------------- # API Gateway REST API 생성 # -------------------------------------- resource "aws_api_gateway_rest_api" "this" { name = "${var.project_name}-${var.environment}-api" description = "PetClinic 애플리케이션용 API Gateway" endpoint_configuration { types = ["REGIONAL"] } ...
kskbr/private_project
Apache-2.0
terraform/modules/api-gateway/main.tf
aws
[ "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_resource", "aws_api_gateway_rest_api", "aws_api_gateway_stage", "aws_cloudwatch_log_group" ]
fa387907f44bf5482f1565f0ffc0223e
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 name tag, provision subnets across specified availability zones with configurable CIDR blocks and public/private flags, attach an internet gateway only if any public subnets exist, create a single route table for public traffic with a default route to the internet gateway...
resource "aws_vpc" "main" { cidr_block = var.vpc_config.cidr_block tags = { Name = var.vpc_config.name } } resource "aws_subnet" "main" { vpc_id = aws_vpc.main.id for_each = var.subnet_config cidr_block = each.value.cidr_block availability_zone = each.value.availability_zone tags = { ...
ankitkings/terraform-aws-ankit-test-vpc
MIT
main.tf
aws
[ "aws_internet_gateway", "aws_route_table", "aws_route_table_association", "aws_subnet", "aws_vpc" ]
fdfce5e644e85cedef6b353045448934
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an ECR repository with the name provided via a variable, configured to mutate image tags, scan images on push, use KMS encryption with a key ARN from a variable, and allow force deletion; attach a lifecycle policy that automatically expires images beyond the latest five, regardless of tag status; and output both...
resource "aws_ecr_repository" "this" { name = var.repository_name image_tag_mutability = "MUTABLE" image_scanning_configuration { scan_on_push = true } encryption_configuration { encryption_type = "KMS" kms_key = var.kms_key_arn } force_delete = true tags = merge(...
simplycycling/flaskanetes
MIT
terraform/modules/ecr/main.tf
aws
[ "aws_ecr_lifecycle_policy", "aws_ecr_repository" ]
16a53463e37b4532b87deaf05ba359cd
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named “ecsInstanceRole” that EC2 instances can assume to join an ECS cluster, attach the AWS-managed policy “AmazonEC2ContainerServiceforEC2Role” to it, and create an IAM instance profile named “ecsInstanceProfile” that wraps the role for use by EC2 instances.
# IAM role for EC2 instances to join ECS cluster resource "aws_iam_role" "ecs_instance_role" { name = "ecsInstanceRole" assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [ { Action = "sts:AssumeRole", Principal = { Service = "ec2.amazonaws.com" },...
benrhine/spring-boot-with-aws-ecs-and-terraform
MIT
terraform/example-gpt-1/iam.tf
aws
[ "aws_iam_instance_profile", "aws_iam_role", "aws_iam_role_policy_attachment" ]
e7622e87584e4229b897498f47694100
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Enforce a strict IAM password policy with configurable minimum length, expiration, complexity requirements, and reuse prevention, and optionally create a custom account alias for the AWS account.
/* * Copyright (c) 2019 Netic A/S. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ resource "aws_iam_account_password_policy" "this" { minimum_password_length = var.minimum_password_length max_password...
neticdk/tf-aws-iam-account
MIT
main.tf
aws
[ "aws_iam_account_alias", "aws_iam_account_password_policy" ]
1154f4d012cbbbb42fc12a8b8d9182e4
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an ElastiCache Redis cluster with one replica per node group, multi-AZ enabled, automatic failover, and both in-transit and at-rest encryption turned on; configure it to use a dedicated subnet group with the specified subnets, a security group allowing inbound and outbound TCP traffic on the Redis port between a...
resource "aws_security_group" "egress" { name = local.security_groups.egress_name description = "Allow outbound traffic to ElastiCache" vpc_id = var.vpc_id } # https://aquasecurity.github.io/tfsec/v1.28.13/checks/aws/elasticache/add-description-for-security-group/ resource "aws_security_group_rule" "...
itsregularjohn/terraform-aws-enterprise-eks
MIT
modules/aws/elasticache/main.tf
aws
[ "aws_cloudwatch_log_group", "aws_elasticache_replication_group", "aws_elasticache_subnet_group", "aws_security_group", "aws_security_group_rule" ]
bdfefbe0f64773b8fbbd6bb8b7bd22c7
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a public Network Load Balancer named with the namespace prefix “-nlb” that routes traffic from configurable listener ports to backend instances via TCP target groups, with health checks every 30 seconds using TCP probes; also configure SSL listeners on additional ports using a self-signed certificate valid for 1...
locals { target_port = [for key, value in var.forwarding_config : value.dest_port] target_port_ssl = [for key, value in var.forwarding_config_ssl : value.dest_port] dest_to_src = zipmap([for key, value in var.forwarding_config : value.dest_port], [for key, value in var.forwarding_config : key]) dest_to_...
PatHoo/gac-tsp
MIT
global/MQTT/modules/elb/main.tf
aws
[ "aws_acm_certificate", "aws_lb", "aws_lb_listener", "aws_lb_target_group", "aws_lb_target_group_attachment", "random_string", "tls_private_key", "tls_self_signed_cert" ]
198b5c49366e085a74660c43dc3396e4
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a CloudWatch Log Group for each Lambda function defined in `lambda_settings`, named using the environment, project, and function name, and set log retention to 14 days.
# This is to optionally manage the CloudWatch Log Group for the Lambda Function. # If skipping this resource configuration, also add "logs:CreateLogGroup" to the IAM policy below. resource "aws_cloudwatch_log_group" "lambda_log_cloudwatch_map" { for_each = local.lambda_settings name = "/aws/lambda/${v...
Andrea-Scuderi/HelloWorldLambda
Apache-2.0
terraform/cloudwatch.tf
aws
[ "aws_cloudwatch_log_group" ]
71474a6c6945ff54dd88d3db673ee458
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an ECS execution role named `<app_name>-ecs-execution-role` with permissions to pull container images and publish logs, attach the managed `AmazonECSTaskExecutionRolePolicy`, and add a custom policy granting access to a specific Secrets Manager secret for database credentials. Create a separate ECS task role nam...
# Data source for current AWS account data "aws_caller_identity" "current" {} # ECS Task Execution Role resource "aws_iam_role" "ecs_execution_role" { name = "${var.app_name}-ecs-execution-role" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole...
driconrikus/koronet-web-test
Apache-2.0
terraform/iam.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
a68a95a0de411671b637240b85ef3743
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a Kali Linux EC2 instance in us-east-1 using the “terraform” AWS profile, with an RSA key pair named “kali”, a public IP, and user data loaded from a specific payload script; use the default subnet in the specified availability zone unless a subnet ID is provided, and set the root volume size according to the...
provider "aws" { region = "us-east-1" profile = "terraform" } resource "tls_private_key" "this" { algorithm = "RSA" } resource "aws_key_pair" "this" { key_name = "kali" public_key = tls_private_key.this.public_key_openssh } data "template_file" "user_data" { template = file(".terraform/modules/ec2-kal...
offensive-terraform/terraform-aws-ec2-kali-linux
Apache-2.0
main.tf
aws
[ "aws_default_subnet", "aws_instance", "aws_key_pair", "tls_private_key" ]
0706a0ebf3f81b3e3b00327527d94387
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an Amazon Cognito identity pool named “my-identity-pool” in the specified AWS region, configured to allow unauthenticated identities and classic flow, with support for developer-provided identities, OpenID Connect, SAML, and social login providers as defined in the variables, and include dynamic Cognito user poo...
resource "aws_cognito_identity_pool" "this" { region = var.region identity_pool_name = var.identity_pool_name allow_unauthenticated_identities = var.allow_unauthenticated_identities allow_classic_flow = var.allow_classic_flow developer_provider_name ...
ebogdum/terraform-providers
MIT
aws/resources/cognito_identity_pool/main.tf
aws
[ "aws_cognito_identity_pool" ]
30e0d86cab476b296bd5b795cbaca3d3
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Lambda alias named LATEST pointing to the latest version of the write_amazon_titan_image_generator_v1_text_image Lambda function.
resource "aws_lambda_alias" "write_amazon_titan_image_generator_v1_text_image" { description = null function_name = aws_lambda_function.write_amazon_titan_image_generator_v1_text_image.arn function_version = "$LATEST" name = "LATEST" }
lindsaygelle/AWSBedrock
MIT
aws_lambda_alias.tf
aws
[ "aws_lambda_alias" ]
bb9f0e334862e71f32cc67c8b976bf93
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named with the pattern `<osdu_instance_service_iam_role_prefix>-<rest_role_name>` that is conditionally deployed only when `deploy_rest_proxy_server_service` is true, allowing the REST service container in EKS to assume the role via OIDC federation, and grant it permissions to write logs to any log g...
# 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-ddms/instance/reservoir-ddms/iam.tf
k8s
[ "aws_iam_role" ]
17f5fda8487da34bcf2323b145570bb3
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 and DNS hostnames enabled, attach an internet gateway to it, and provision one subnet within that VPC using 10.0.0.0/24 that automatically assigns public IP addresses to new instances.
resource "aws_vpc" "vpcforwebapp" { cidr_block = "10.0.0.0/16" enable_dns_hostnames = true } resource "aws_internet_gateway" "igw" { vpc_id = aws_vpc.vpcforwebapp.id } resource "aws_subnet" "subnet1forwebapp" { cidr_block = "10.0.0.0/24" vpc_id = aws_vpc.vpcforwebap...
vishipayyallore/learn-terraform-in-2023
MIT
Source/AWS/WebApps/a1-ec2-web-app/a3-networking.tf
aws
[ "aws_internet_gateway", "aws_subnet", "aws_vpc" ]
2867d5664f1e21492ec5d8ab11ef856a
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a CloudTrail trail named “Audit” that logs to an S3 bucket with a name derived from the environment label and name (lowercased and space-replaced), ensures the bucket is cleaned up after a configurable number of days, blocks incomplete multipart uploads after one day, and grants the CloudTrail service permission...
resource "aws_cloudtrail" "audit" { name = "Audit" s3_bucket_name = aws_s3_bucket.cloudtrail.bucket is_multi_region_trail = true enable_log_file_validation = true tags = { Name = "CloudTrail // ${var.environment_label} ${var.environment_name}" Environment...
jay-li-0202/aws-infrastructure
MIT
environment/modules/bootstrap/cloudtrail.tf
aws
[ "aws_cloudtrail", "aws_s3_bucket", "aws_s3_bucket_policy" ]
dc20d689ecabb8e72deb047ea7836af4
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision two web servers in separate availability zones, each using the latest fast AMI, the instance type specified by the variable, the bastion key pair for SSH access, a shared security group for web traffic, and no public IP address—name them with the local prefix plus “-web-server-1” and “-web-server-2”, assign t...
data "aws_availability_zones" "available_for_private" { state = "available" } resource "aws_instance" "web_server_1" { ami = data.aws_ami.fast_ami.id instance_type = var.instance_type key_name = aws_key_pair.bastion_keypair.key_name vpc_security_group_ids = [...
Engenharia-de-Plataforma-FAST/fast-iac
MIT
lab-aws/terraform/infra-02/private_instances.tf
aws
[ "aws_instance" ]
10f9cd8b66d89eba9ca7426de9064674
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a virtual private cloud with two public subnets across two availability zones, an internet gateway attached to the VPC, a public route table directing all traffic to the internet gateway, and associate both subnets with that route table; create a security group allowing inbound HTTP traffic from a configurabl...
/* * Core networking and compute resources for the 3‑tier architecture. This file * defines the VPC, public subnets, routing, security groups and the EC2 web * server. All resources are tagged via the locals defined in locals.tf. */ # # VPC and public networking # resource "aws_vpc" "main" { cidr_block ...
AFP9272000/aws-3tier-terraform
MIT
main.tf
aws
[ "aws_instance", "aws_internet_gateway", "aws_route", "aws_route_table", "aws_route_table_association", "aws_security_group", "aws_subnet", "aws_vpc" ]
367c793e7f6a9695e3ac45c2568d4c49
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create CloudWatch log groups for each enabled Aurora database log type, naming each log group `/aws/rds/cluster/<cluster-name>/<log-type>`, setting the log retention period to the value specified in `var.aurora_config.log_retention_in_days`, and encrypting the logs using the KMS key associated with the Aurora CloudWatc...
resource "aws_cloudwatch_log_group" "aurora" { for_each = toset(var.aurora_config.enabled_cloudwatch_logs_exports) name = "/aws/rds/cluster/${local.cluster_identifier}/${each.value}" retention_in_days = var.aurora_config.log_retention_in_days kms_key_id = aws_kms_key.aurora_cloudwatch.arn ...
SpaceRocketDev/aws-app-platform
Apache-2.0
modules/aurora/cloudwatch.tf
aws
[ "aws_cloudwatch_log_group" ]
ed1ec745354cc061d7abe2cad10b7521
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, named using the provided name, environment, and suffix variables, and assign it a CIDR block from a variable. Provision public, private, and database subnets across the specified availability zones, assigning each subnet a CIDR block from corresponding variables, tag...
resource "aws_vpc" "this" { cidr_block = var.cidr enable_dns_hostnames = true enable_dns_support = true tags = merge( { "Name" = "vpc-${var.name}-${var.environment}-${var.suffix}" }, var.tags ) } resource "aws_subnet" "public" { count = length(var.public_subnets) availability_z...
migueleiva/workshop-terraform-2024-abril
Apache-2.0
ejercicio-modulos/modules/vpc/resources.tf
aws
[ "aws_internet_gateway", "aws_nat_gateway", "aws_route", "aws_route_table", "aws_route_table_association", "aws_subnet", "aws_vpc", "aws_vpn_gateway" ]
96a189aa6e2ea78bce013f156219951e
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Associate subnet `sec1-sub` with route table `sec1-tgw-sub-route` and subnet `sec2-sub` with route table `sec2-fw-sub-route`.
resource "aws_route_table_association" "tgw-sub-association" { subnet_id = aws_subnet.sec1-sub.id route_table_id = aws_route_table.sec1-tgw-sub-route.id } resource "aws_route_table_association" "fw-sub-association" { subnet_id = aws_subnet.sec2-sub.id route_table_id = aws_route_table.sec2-fw-sub-rout...
tendai-lino/training
Apache-2.0
GWLB-DEMO/subnet-routes-association.tf
aws
[ "aws_route_table_association" ]
80b33534d4d1e00592ec3b208f0dcb73
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a scalable web server fleet in the Asia Pacific (Seoul) region using an Auto Scaling group with a minimum of two and maximum of four instances, launched from a launch template that installs and configures an HTTP server on a configurable port, uses the latest Amazon Linux 2023 AMI, and attaches to the default...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { region = "ap-northeast-2" # Asia Pacific (Seoul) region } /* resource "aws_instance" "web" { ami = var.image_id # "ami-0c1508b5372d244d7" # Amazon Linux 2023 (ap-nor...
JEONGHO0316/Study_Bespin
Apache-2.0
terraform-labs/105-asg/main.tf
aws
[ "aws_autoscaling_group", "aws_instance", "aws_key_pair", "aws_launch_template", "aws_security_group" ]
d307e2584f5c245682a848134563c9da
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Request an ACM certificate for the account’s hosted zone domain, including a wildcard SAN for all subdomains, with DNS validation records automatically created in Route 53 using a 60-second TTL and allowing overwrites, then validate the certificate once all DNS records are in place.
# # For now avoid having more than one SAN (Subject Alternative Name). # # https://github.com/terraform-providers/terraform-provider-aws/issues/8531 # resource "aws_acm_certificate" "jenkins_cert" { domain_name = local.account_hosted_zone.domain subject_alternative_names = [ "*.${local.account_hosted_zone.d...
cicdenv/cicdenv
MIT
terraform/jenkins/shared/acm.tf
aws
[ "aws_acm_certificate", "aws_acm_certificate_validation", "aws_route53_record" ]
ab4321b3678fd10cb4488394b57e5f60
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named “ejemplo-s3-bucket” configured to serve a static website with index.html as the homepage and error.html as the error page, ensure public read access is enabled for all objects in the bucket, and upload the local index.html and error.html files from the asset directory with appropriate content ...
# Configuración del proveedor AWS provider "aws" { region = var.aws_region # Define la región de AWS donde se crearán los recursos, obtenida de la variable 'aws_region'. } resource "aws_s3_bucket" "ejemplo_s3_bucket" { bucket = "ejemplo-s3-bucket" tags = { Name = "S3 bucket para alojar la web" En...
pduran5/cloud
BSD-3-Clause
old/2-storage/2.2-s3-static-web/aws.tf
aws
[ "aws_s3_bucket", "aws_s3_bucket_policy", "aws_s3_bucket_public_access_block", "aws_s3_bucket_website_configuration", "aws_s3_object" ]
26e193ca09878228f143da1919c1e484
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an ML database in AWS Glue Catalog named with the project prefix and suffixed with “-ml-db”, set up a Glue connection to an RDS MySQL database using provided host, port, and database parameters, and configure it to connect via a specific private subnet and security group. Set up a Glue crawler named with the pro...
resource "aws_glue_catalog_database" "ml_database" { name = "${var.project}-ml-db" description = "Database for performing ml from OLTP data" } resource "aws_glue_connection" "rds_connection" { name = "${var.project}-rds-connection" connection_properties = { JDBC_CONNECTION_URL = "jdbc:mysq...
LoicSteve/Batch-and-Streaming-pipeline-on-AWS
Apache-2.0
terraform/modules/etl/glue.tf
aws
[ "aws_glue_catalog_database", "aws_glue_connection", "aws_glue_crawler", "aws_glue_job" ]
6a5fc78839af5c88f9d4d2263b3d2cfd
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a target tracking scaling policy named with the cluster and service name that scales based on the average number of requests per target in the specified Application Load Balancer target group, using the CPU utilization metric value provided, with configurable scale-in and scale-out cooldown periods.
resource "aws_appautoscaling_policy" "target_tracking_requests" { count = var.scale_type == "requests_tracking" ? 1 : 0 name = format("%s-%s-requests-tracking", var.cluster_name, var.service_name) resource_id = aws_appautoscaling_target.main.resource_id service_namespace = aws_appautoscaling_target.m...
fabrijob/ecs-service-module
MIT
autoscaling_tracking_requests.tf
aws
[ "aws_appautoscaling_policy" ]
56852dff49a6b554bf7c56862fad1327
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named `iam_for_lambda` that AWS Lambda can assume, zip the `lambda.js` file into `lambda_function_payload.zip`, and deploy a Lambda function named `lambda_function_name` using Node.js 16.x runtime with the handler `lambda.handler`, environment variable `foo` set to `bar`, and the zipped code file as ...
data "aws_iam_policy_document" "assume_role" { statement { effect = "Allow" principals { type = "Service" identifiers = ["lambda.amazonaws.com"] } actions = ["sts:AssumeRole"] } } resource "aws_iam_role" "iam_for_lambda" { name = "iam_for_lambda" assume_role_p...
apurbagiri/terraform-cloud
Apache-2.0
lambda.tf
aws
[ "aws_iam_role", "aws_lambda_function" ]
3b48a03d07d0d7d3f3fd87fa84939434
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named `<prefix>-cloudtrail-bucket` with server-side encryption using a KMS key, lifecycle rules to expire objects after 7 days, and public access blocked. Set up a second S3 bucket named `<prefix>-cloudtrail-bucket-logs` with the log-delivery-write ACL and public access blocked, configured as the ta...
data "aws_caller_identity" "current" {} locals { s3_bucket_log_prefix = "cloudtrail_logs" cloud_trail_bucket_name = "${var.prefix}-cloudtrail-bucket" cloud_trail_bucket_logs = "${var.prefix}-cloudtrail-bucket-logs" } resource "aws_kms_key" "cloudtrail_kms_key" { description = "${var.prefix}-clo...
uk-gov-mirror/ministryofjustice.staff-device-logging-infrastructure
MIT
modules/cloudtrail/main.tf
aws
[ "aws_cloudtrail", "aws_cloudwatch_log_group", "aws_kms_alias", "aws_kms_key", "aws_s3_bucket", "aws_s3_bucket_public_access_block" ]
2729dab076f0470278d65d875984a9c1
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a DynamoDB table named odi-tf-state-lock with a string primary key called LockID, provisioned throughput of 20 read and 20 write capacity units, and enable streaming with both new and old image views.
resource "aws_dynamodb_table" "odi-tf-state-lock" { name = "odi-tf-state-lock" hash_key = "LockID" billing_mode = "PROVISIONED" read_capacity = 20 write_capacity = 20 stream_enabled = true stream_view_type = "NEW_AND_OLD_IMAGES" attribute { name = "LockID" type = "...
odirasamuel/R_n_D
MIT
s3_backend/dynamodb.tf
aws
[ "aws_dynamodb_table" ]
4b0cbb23a13f2abecb9db72f2eb47f31
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Deploy version 1.14.1 of the AWS Load Balancer Controller Helm chart into the kube-system namespace, using the specified cluster name and VPC ID, and reuse the existing aws-load-balancer-controller service account instead of creating a new one, with automatic cleanup on deployment failure.
resource "helm_release" "eks_helm_controller" { name = "aws-load-balancer-controller" repository = "https://aws.github.io/eks-charts" chart = "aws-load-balancer-controller" version = "1.14.1" namespace = "kube-system" cleanup_on_fail = true set = [ { name = "clusterName" ...
guilhermekonell/terraform-course
MIT
modules/aws-load-balancer-controller/helm.tf
aws
[ "helm_release" ]
842d66a10bc6dc3926b39b6cb8b0af67
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an SQS queue with a configurable name and visibility timeout, paired with a dedicated dead-letter queue named by appending `-dlq` to the main queue’s name, configure the main queue to retry failed messages up to 12 times before sending them to the dead-letter queue, and optionally subscribe the main queue to one...
variable "name" { type = string description = "SQS Name" } variable "visibility_timeout_seconds" { type = number description = "SQS Visibility Timeout in Seconds" } variable "sns_subscriptions_arns" { type = list(string) default = [] description = "SNS Topic ARNs to subscribe to...
comtravo/terraform-modules
MIT
sqs/main.tf
aws
[ "aws_sns_topic_subscription", "aws_sqs_queue", "aws_sqs_queue_policy" ]
14ae020339543ca2d30a9cd10b5679b4
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group in the main VPC that permits inbound SSH (port 22), Juju (port 17070), ICMP, HTTP (port 80), and HTTPS (port 443) traffic only from the IP addresses specified in the SOURCE_ADDRESSES variable, and allow all outbound traffic to any destination.
# Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. ## ==================================================== ## Network Security Group for SSH Access ## ==================================================== resource "aws_security_group" "main_nsg" { vpc_id = aws_vpc.main_vpc.id ingress { ...
canonical/charms-reference-architectures
Apache-2.0
clouds/aws/security_groups.tf
aws
[ "aws_security_group" ]
33808076043ac935b38008d698c8a793
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM policy named “mattermost-gitlab-runner-policy” that grants S3 permissions—including putting objects, getting objects and their versions, and deleting objects—to a specific S3 bucket used for GitLab runners, then create an IAM role named “mattermost-gitlab-runner-role” that allows the EKS worker node role ...
resource "aws_iam_policy" "s3" { name = "mattermost-gitlab-runner-policy" path = "/" description = "S3 Permissions for gitlab runners" policy = <<EOF { "Version": "2012-10-17", "Statement": [ { "Sid": "route53", "Effect": "Allow", "Action": [ ...
mattermost/mattermost-cloud-monitoring
Apache-2.0
aws/gitlab-runner/iam.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
95ea7568fe3285163ba478399b713b83
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a bastion host in a specified subnet of a given VPC, using the latest Amazon Linux 2 AMI for x86_64 architecture, with a public IP, the provided key pair, and an instance type defined by a variable. Set up a security group allowing SSH access (port 22) from anywhere on the internet to the bastion host, and anoth...
data "aws_ami" "amazon-linux-2" { most_recent = true owners = ["amazon"] filter { name = "architecture" values = ["x86_64"] } filter { name = "name" values = ["amzn2-ami-hvm*"] } } locals { bastion_name = "${var.cluster_name}-bastion-byo" } resource "aws_instance" "bastion" { ami ...
aaroniscode/cluster-api-aws-toolkit
MIT
v1alpha2/02-aws-resources/capa_bastion/main.tf
aws
[ "aws_instance", "aws_security_group" ]
444d368b326a1e61d4b6afc19fc3e606
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create two IAM roles named `<name>-lambda-consumer` and `<name>-lambda-processor`, each assumable by the Lambda service, where the consumer role grants permissions to write logs for its Lambda functions and read from a specific Kinesis stream, and the processor role grants the same log and Kinesis permissions plus perm...
resource "aws_iam_role" "lambda_consumer" { name = "${local.name}-lambda-consumer" assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [ { Action = "sts:AssumeRole", Effect = "Allow", Principal = { Service = "lambda.amazonaws.com" } } ...
jajera/tf-aws-kinesis-lambda
MIT
iam.tf
aws
[ "aws_iam_role", "aws_iam_role_policy" ]
ed248142745537d61b636ed8c867ba2a
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an SNS topic named “terraform-state-changes” that only allows the S3 service to publish messages to it, and restrict that permission to messages originating exclusively from a specific S3 bucket.
resource "aws_sns_topic" "state_changes" { name = "terraform-state-changes" } resource "aws_sns_topic_policy" "state_changes" { arn = aws_sns_topic.state_changes.arn policy = data.aws_iam_policy_document.sns_topic_policy.json } data "aws_iam_policy_document" "sns_topic_policy" { statement { effect = "All...
itsregularjohn/terraform-aws-enterprise-eks
MIT
accounts/management/global/00-terraform-state-security/sns.tf
aws
[ "aws_sns_topic", "aws_sns_topic_policy" ]
e0da46cb9601b21fef8d8c1f12e57f4a
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a KMS key with key rotation enabled, a policy that grants full KMS permissions to the account’s IAM root user and specific encryption-related permissions to the CloudWatch Logs service in the specified region, and name the key with an alias matching the environment and service name provided via variables.
resource "aws_kms_key" "kms" { description = "KMS Key for the ${var.name}-${var.env} environment" enable_key_rotation = "true" policy = <<POLICY { "Version": "2012-10-17", "Id": "${var.name}-${var.env}-kms-policy", "Statement": [ { "Sid" : "Enable IAM User Permiss...
amirmb/ecs-terraform
Apache-2.0
modules/kms/main.tf
aws
[ "aws_kms_alias", "aws_kms_key" ]
123c473b66bdc8eff543543e59a6a55f
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named `amplify-build-role` that AWS Amplify can assume, granting it full Amplify administrative permissions via the `AdministratorAccess-Amplify` managed policy.
resource "aws_iam_role" "amplify_build_role" { name = "amplify-build-role" assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [ { Effect = "Allow", Principal = { Service = [ "amplify.${var.aws_region}.amazonaws.com", "amplify.amazon...
Falltrades/cloud-example
MIT
static-website/aws-amplify/terraform/iam.tf
aws
[ "aws_iam_role", "aws_iam_role_policy_attachment" ]
90f9dfa0ebf3160129f3875a98310486
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named via the `security_group_name` variable, named “Security Group for EC2 instance”, that allows inbound HTTP (port 80) and HTTPS (port 443) traffic from anywhere, and permits all outbound traffic to any destination.
resource "aws_security_group" "security_group6" { name = var.security_group_name description = "Security Group for EC2 instance" #entree ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } ingress { from_port = 443 to...
IPSSI2022/terraform_groupe6_ipssi
Unlicense
terraform/APP/modules/security_group/main.tf
aws
[ "aws_security_group" ]
37d823ee48b0fc284d1ed3d48a926482
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a KMS key named “cw_loggroup_kms_key” for encrypting CloudWatch log groups, with key rotation optionally enabled, a configurable deletion window, and a symmetric key for encryption and decryption. Attach a key policy that grants full administrative access to the account’s root IAM user and grants the CloudWatch ...
data "aws_caller_identity" "current" {} data "aws_region" "current" {} resource "aws_kms_key" "cw_loggroup_kms_key" { description = "KMS key for encrypting CloudWatch log groups" enable_key_rotation = var.enable_key_rotation deletion_window_in_days = var.kms_deletion_window_in_days ...
Spandan-Malpani/Multi-Account-EBS-Audit
MIT
modules/kms/main.tf
aws
[ "aws_kms_key", "aws_kms_key_policy" ]
655d2b950b500ec6621c8fcb145945b5
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create two public subnets in the same VPC: one in the availability zone specified by `public_az_1` with the CIDR block defined by `public_cidr_1`, and another in the availability zone specified by `public_az_2` with the CIDR block defined by `public_cidr_2`.
resource "aws_subnet" "public_1" { vpc_id = join("", aws_vpc.vpc.*.id) cidr_block = var.public_cidr_1 availability_zone = var.public_az_1 } resource "aws_subnet" "public_2" { vpc_id = join("", aws_vpc.vpc.*.id) cidr_block = var.public_cidr_2 availability_zone = var.publ...
fiap5dvp/terraform
MIT
modules/vpc/subnets.tf
aws
[ "aws_subnet" ]
f757fe2fe364b3036da7a18433b73c83
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM policy named with the namespace and environment that grants permissions to read all SSM Parameter Store parameters, write logs, list all S3 buckets, and fully manage an S3 bucket specifically named for SSM backups (including listing, getting, putting, deleting, and managing ACLs and versions), plus KMS pe...
resource "aws_iam_policy" "this" { name = "${var.namespace}-${var.environment}-ssm-parameter-store-backup-policy" policy = jsonencode({ Version = "2012-10-17", Statement = [ { Effect = "Allow", Action = [ "ssm:DescribeParameters", "ssm:GetParameterHistory", ...
abdullahkhawer/aws-ssm-parameter-store-backup
Apache-2.0
iam.tf
aws
[ "aws_iam_policy", "aws_iam_role" ]
9c6d1a08db1e1b2f553d1b98527c37ba
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision an EC2 instance using a specific AMI and instance type, name it using a variable, and associate it with a key pair named “terraform-test” whose public key is read from the file “terraform-test.pub”, all deployed in the AWS region and with credentials specified via variables.
provider "aws" { access_key = var.AWS_ACCESS_KEY secret_key = var.AWS_SECRET_KEY region = var.AWS_REGION } resource "aws_instance" "example" { ami = var.AWS_AMI_ID instance_type = var.AWS_INSTANCE_TYPE key_name = "terraform-test" tags = { Name = var.AWS_INSTANCE_NAME } } resource "aw...
zelaskov/terraform_base
MIT
provision_ec2/ec2.tf
aws
[ "aws_instance", "aws_key_pair" ]
399256d531839519dc46812f33fcf695
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a launch template named with the prefix `-selfmanaged-lt` that uses a specified AMI, instance type, and key pair, joins a given security group, and includes user data script configured for an EKS cluster with the provided cluster name, endpoint, and capacity type; attach the specified IAM instance profile, tag i...
resource "aws_launch_template" "eks-lt" { name_prefix = "${var.prefix}-selfmanaged-lt" image_id = var.worker_image_id instance_type = var.instance_type key_name = var.Key_Name vpc_security_group_ids = [var.eks_nodes_sg_id] user_data = base64encode(templatefil...
Hendawyy/private-eks-cluster-fully-on-outposts
MIT
modules/WorkerNodes/LaunchTemplate.tf
aws
[ "aws_launch_template" ]
573a65b03c4ab187af3e7f4ee63e2615
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create one or more Recycle Bin (RBin) rules for AWS resources, each configured with a specified resource type and description, a retention period defined by a unit and value (e.g., days or months), optional resource tags to target specific resources, and an optional lock configuration that includes an unlock delay defi...
resource "aws_rbin_rule" "this" { for_each = { for k, v in var.rbin_rules : k => v if var.create } resource_type = each.value.resource_type description = each.value.description dynamic "retention_period" { for_each = length(each.value.retention_period) > 0 ? [true] : [] content { retention_per...
magreenbaum/terraform-aws-rbin
MIT
main.tf
aws
[ "aws_rbin_rule" ]
d8817b5839ca11173aaaeaeb944f0aea
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a default security group in the specified VPC that allows all inbound and outbound traffic from any IP address, and tag it with a name derived from common tags appended with “-default-sec_grp”.
#default secrity group is a vpc level resource resource "aws_default_security_group" "my_sec_group" { vpc_id = aws_vpc.my_vpc.id ingress { from_port = 0 to_port = 0 protocol = -1 cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = -1 ci...
Merch7x/My_Terraform_Templates
MIT
Aws_templates/Modules/Vpc/security.tf
aws
[ "aws_default_security_group" ]
f0fa999b4c59e8429e54121fa1e9251c
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an RDS shard group in the specified region with the given database cluster, using the provided shard group identifier, compute redundancy level, and ACU range (minimum and maximum), make it publicly accessible if required, apply the given tags, and configure creation, update, and deletion timeouts.
resource "aws_rds_shard_group" "this" { region = var.region compute_redundancy = var.compute_redundancy db_cluster_identifier = var.db_cluster_identifier db_shard_group_identifier = var.db_shard_group_identifier max_acu = var.max_acu min_acu ...
ebogdum/terraform-providers
MIT
aws/resources/rds_shard_group/main.tf
aws
[ "aws_rds_shard_group" ]
a8f6400fd5c1270b5562e56ea1613b94