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 EC2 Network Insights path to analyze network connectivity between a specified source resource and destination, using a given protocol, IP addresses, and destination port; optionally include filtering criteria at both the source and destination, each with optional source and destination IP addresses and port r...
resource "aws_ec2_network_insights_path" "this" { source = var.source_resource protocol = var.protocol region = var.region source_ip = var.source_ip destination = var.destination destination_ip = var.destination_ip destination_port = var.destination_port dynamic "filter_at_de...
ebogdum/terraform-providers
MIT
aws/resources/ec2_network_insights_path/main.tf
aws
[ "aws_ec2_network_insights_path" ]
2ef4b984ad4b8e81456674cd4c1c7c14
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM policy named after the instance profile with the suffix `-ssm-policy` that grants full permissions to all SSM, SSM Messages, and EC2 Messages actions across all resources, attach it to the EC2 instance profile’s IAM role, and only create the policy and attachment if the `ssm_policy` variable is enabled.
#tfsec:ignore:aws-iam-no-policy-wildcards -- Ignores warning on wildcarded resources data "aws_iam_policy_document" "ssm" { statement { sid = "ssm" actions = [ "ssm:DescribeAssociation", "ssm:GetDeployablePatchSnapshotForInstance", "ssm:GetDocument", "ssm:DescribeDocument", "ssm...
StratusGrid/terraform-aws-ec2-instance-profile-builder
Apache-2.0
iam-policy-ssm.tf
aws
[ "aws_iam_policy", "aws_iam_role_policy_attachment" ]
e72e4eac871dd0f4766c435dd0641884
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role for a Lambda function named using the environment, service, and region shortname, allowing it to assume the role via the Lambda service principal; attach a policy granting full permissions to create and manage CloudWatch Logs resources and to create, describe, delete, and assign/unassign Elastic Netw...
resource "aws_iam_role" "readme_service_lambda_role" { name = "${var.environment_name}-${var.service_name}-lambda-role-${data.terraform_remote_state.region.outputs.aws_region_shortname}" assume_role_policy = <<EOF { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", "Principa...
Pennsieve/readme-service
Apache-2.0
terraform/iam.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
5a192b8df52c5bf5eb0421f3e967556f
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision an EC2 instance using the specified AMI and instance type, assign it the provided key pair and IAM instance profile, place it in the given subnet with the listed security groups, enable strict IMDSv2 metadata access, enable EBS optimization, encrypt the root volume, activate detailed CloudWatch monitoring, in...
resource "aws_instance" "instance" { ami = var.ami instance_type = var.instance_type key_name = var.key_name iam_instance_profile = var.instance_profile_name subnet_id = var.subnet_id vpc_security_group_ids = var.ec2_security_groups_ids metadata_options ...
StamenchoBog/smart-home
MIT
external_systems/infra/terraform/aws/modules/ec2/instance.tf
aws
[ "aws_instance" ]
edf9abd9f28b1bc66b47291132d31d4b
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an ECS cluster named using the local ID variable, with container insights either enabled or disabled based on the container_insights_enabled variable, and configure it to use FARGATE as the sole capacity provider with a default strategy that always runs one task on FARGATE.
resource "aws_ecs_cluster" "this" { name = local.id setting { name = "containerInsights" value = var.container_insights_enabled ? "enabled" : "disabled" } lifecycle { ignore_changes = [name] } } resource "aws_ecs_cluster_capacity_providers" "this" { cluster_name = aws_ecs_cluster.this....
champ-oss/terraform-aws-fargate
CC0-1.0
cluster.tf
aws
[ "aws_ecs_cluster", "aws_ecs_cluster_capacity_providers" ]
f77d18a072b70722303fb38462584222
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a CloudFront distribution that serves a static website hosted in an S3 bucket named `shopping_list_frontend_bucket`, using origin access control with Sigv4 signing to restrict direct public access to the bucket, with HTTPS enforced for all viewers, IPv6 enabled, and a custom 403 error response that redirects to ...
locals { s3_origin_id = "shopping_list_frontend_origin" } resource "aws_cloudfront_origin_access_control" "this" { name = "shopping_list_frontend_bucket" description = "" origin_access_control_origin_type = "s3" signing_behavior = "always" ...
Parziwal/shopping-list-aws-demo
MIT
tf/frontend/cloudfront.tf
aws
[ "aws_cloudfront_distribution", "aws_cloudfront_origin_access_control" ]
23d58423f7ed9ad2bb994163a75c0448
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a single t2.micro Ubuntu EC2 instance named Gophish-Server if gophish_enabled is true, using the specified SSH key pair and security group, then copy a Gophish Ansible playbook to it, install Go, Ansible, and related packages, run the playbook to deploy Gophish, wait 15 seconds, and extract the initial login ...
resource "aws_instance" "gophish-server" { depends_on = [ aws_key_pair.C2structor-keypair ] count = var.gophish_enabled ? 1 : 0 ami = data.aws_ami.ubuntu_image.id instance_type = "t2.micro" key_name = var.ssh-keypair-name vpc_security_group_ids = [ aws_security_group.sg-ssh_access.id ] tags = { Name...
optionalCTF/C2structor
MIT
phishing.tf
aws
[ "aws_instance" ]
89ca8f4ae2285322109adb6757bafc53
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named “ec2-security-group” that allows inbound HTTP traffic on port 80 from any IP address, and allow all outbound traffic to any destination.
resource "aws_security_group" "ec2_security_group" { name = "ec2-security-group" ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = "-1" //all prtocals cidr_blocks = ["0.0.0.0/0"] ...
mahir-makwana/terraform-aws-ec2-nginx-module
MIT
securitygroup.tf
aws
[ "aws_security_group" ]
e4bf5a2306eec5c679b93767b0bff85e
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM SAML identity provider using the provided metadata document, name it according to the variable `name`, and apply the tags specified in the `tags` variable.
resource "aws_iam_saml_provider" "this" { name = var.name saml_metadata_document = var.saml_metadata_document tags = var.tags }
ebogdum/terraform-providers
MIT
aws/resources/iam_saml_provider/main.tf
aws
[ "aws_iam_saml_provider" ]
5a89d7afdb08d1da87a15015215961c2
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an output named `minecraft_server_ip` that exposes the public IP address of the Minecraft server instance, and write that same IP address to a local file named after the server instance (e.g., `myserver-ip-address.log`) in the current working directory.
output "minecraft_server_ip" { value = aws_instance.minecraft_host.public_ip } resource "local_file" "minecraft_server_ip_file" { filename = "${var.minecraft_server_name}-ip-address.log" content = aws_instance.minecraft_host.public_ip }
juanvf/minecraft-installer
MIT
outputs.tf
aws
[ "local_file" ]
648c702d6e0bcb7ca501a037567173be
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 10.0.0.0/16 named “vpc-terraform”, and create either three subnets spaced evenly across that VPC in the production workspace or just one subnet in all other workspaces, each subnet named “subnet-terraform-0” through “subnet-terraform-2” as appropriate.
resource "aws_vpc" "vpc" { cidr_block = "10.0.0.0/16" tags = { Name = "vpc-terraform" } } resource "aws_subnet" "subnet" { count = terraform.workspace == "prod" ? 3 : 1 // se o workspace for == prod, construir 3 subnets; se nao for == prod, construir somente 1 vpc_id = aws_vpc.vpc.id cidr_blo...
VitorSatake/Terraform
MIT
workspaces-aws-vpc/network.tf
aws
[ "aws_subnet", "aws_vpc" ]
899b7d80c87be9013a1bb82ecd610879
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named `role_cidr_house` that allows Lambda functions to assume it, specifically those in the cidr-house-rules account for dev and prod stages across any region, and attach a policy granting permission to describe all EC2 and Elastic Load Balancing resources.
// main tf file for Cidr-house-rules-role data "aws_iam_policy_document" "cidr_house_assume_role" { statement { effect = "Allow" actions = ["sts:AssumeRole"] principals { type = "Service" identifiers = ["lambda.amazonaws.com"] } principals { type = "AWS" identif...
trulia/cidr-house-rules-role
MIT
main.tf
aws
[ "aws_iam_role", "aws_iam_role_policy" ]
1677e2d465cad4b16591870d34cb4a1e
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 environment with the suffix `-list-bookings-iam-role` that allows Lambda functions to scan the bookings DynamoDB table, and store its ARN in Systems Manager Parameter Store under the same environment-prefixed name as a string parameter.
resource "aws_iam_role" "list_bookings_iam_role" { name = "${var.environment}-list-bookings-iam-role" description = "This is a role that allow lambda functions scan dynamodb bookings table" assume_role_policy = templatefile("${path.module}/templates/lambda-base-policy.tpl", {}) } resource "aws_ssm_parameter" "li...
andreciornavei/serverless
MIT
terraform/infra/bookings/iam-role-list-bookings.tf
aws
[ "aws_iam_role", "aws_ssm_parameter" ]
b7a257d733039a31b721972c95088aa4
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named “EKS” in the specified VPC to serve all nodes in the Kubernetes cluster, allowing all outbound traffic, enabling full internal node-to-node communication on all ports and protocols, permitting worker nodes to receive traffic from the cluster control plane on ports 1025 to 65535, and allowi...
resource "aws_security_group" "sg_nodes" { name = var.name == "prod" ? "EKS" : "sg_nodes" description = "Security group for all nodes in the k8s cluster" vpc_id = var.vpc_id egress { description = "Security group rule for all nodes" from_port = 0 to_port = 0 protocol = "-1"...
kutlayakyurek/crossplane-auth-module
Apache-2.0
tf/modules/eks_nodes/security.tf
aws
[ "aws_security_group", "aws_security_group_rule" ]
b9f89c30fabce585f1916c55dab813c2
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a VPC endpoint for Amazon S3 in the current region, attach a policy that allows access only to specific S3 buckets and their objects for the actions ListBucket, GetObject, and PutObject, and ensure the endpoint is tagged consistently with other resources using the provided tags variable.
data "aws_region" "current" {} resource "aws_vpc_endpoint" "s3" { vpc_id = var.vpc_id service_name = "com.amazonaws.${data.aws_region.current.name}.s3" tags = var.tags } resource "aws_vpc_endpoint_policy" "s3" { vpc_endpoint_id = aws_vpc_endpoint.s3.id policy = jsonencode({ "Version": "2012-10-17...
arkdna/terraform-aws-private_s3_endpoint
MIT
endpoint.tf
aws
[ "aws_vpc_endpoint", "aws_vpc_endpoint_policy" ]
802c498f8f19631bb7e3ab4253e48c65
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named using the value of `local.role_name` with path `/service-role/` that can be assumed by the CodePipeline service, and only create it if `var.role_arn` is empty (i.e., when no existing role ARN is provided).
resource "aws_iam_role" "pipeline" { count = var.role_arn == "" ? 1 : 0 name = local.role_name path = "/service-role/" assume_role_policy = <<POLICY { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "codepipeline.a...
JamesWoolfenden/terraform-aws-codepipeline
Apache-2.0
aws_iam_role.pipeline.tf
aws
[ "aws_iam_role" ]
bef59ca4563bc2c6533ea5d304874763
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, environment, and name variables, with server-side encryption enabled using AES256, and optionally enable versioning based on the enable_versioning variable.
resource "aws_s3_bucket" "main" { bucket = "${var.project}-${var.environment}-${var.name}" tags = var.tags } resource "aws_s3_bucket_server_side_encryption_configuration" "main" { bucket = aws_s3_bucket.main.id rule { apply_server_side_encryption_by_default { sse_algorithm = "AES256" } } } ...
opstimus/terraform-aws-s3-bucket
Apache-2.0
main.tf
aws
[ "aws_s3_bucket", "aws_s3_bucket_server_side_encryption_configuration", "aws_s3_bucket_versioning" ]
5846a1c0a86401872d08d875efe5f53f
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 DeleteDatabases that executes a workflow defined in the sfn.json file, using an IAM role named sfn-DeleteDatabases that allows the Step Functions service to assume it, and attach a policy to that role granting permission to describe and delete any RDS database instance.
resource "aws_sfn_state_machine" "main" { name = "DeleteDatabases" definition = file("${path.module}/sfn.json") role_arn = aws_iam_role.sfn.arn } resource "aws_iam_role" "sfn" { name = "sfn-DeleteDatabases" assume_role_policy = data.aws_iam_policy_document.sfn_assume_role.json } data "...
int128/hello-sfn
Apache-2.0
delete-databases/sfn.tf
aws
[ "aws_iam_role", "aws_iam_role_policy", "aws_sfn_state_machine" ]
26e1ad27e962e07ff8768489e12540cf
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a VPC named “terraform demo” with DNS support and hostnames enabled, using a CIDR block defined by `var.vpccidr`. Provision four pairs of subnets across two availability zones: public subnets in az1 and az2, private subnets in az1 and az2, high-availability sync subnets in az1 and az2, and high-availability mana...
// AWS VPC resource "aws_vpc" "fgtvm-vpc" { cidr_block = var.vpccidr enable_dns_support = true enable_dns_hostnames = true instance_tenancy = "default" tags = { Name = "terraform demo" } } resource "aws_subnet" "publicsubnetaz1" { vpc_id = aws_vpc.fgtvm-vpc.id cidr_block...
jenkins611/FortiOS
MIT
aws/7.4/ha-endpoint/vpc.tf
aws
[ "aws_subnet", "aws_vpc", "aws_vpc_endpoint" ]
16b0d990046b342a67d85f5a30f46b79
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an EKS managed node group named after the project with exactly one node, deployed across two private subnets, using a dedicated IAM role for the node group that includes policies for worker node access, ECR, and CNI.
resource "aws_eks_node_group" "eks_managed_node_group" { cluster_name = var.cluster_name node_group_name = "${var.project_name}node-group" node_role_arn = aws_iam_role.eks_mng_role.arn subnet_ids = [ var.subnet_private_1a, var.subnet_private_1b ] tags = merge( var.tags, { Name = "...
Shha256/cluster_tf
MIT
modules/managed-node-group/mng.tf
aws
[ "aws_eks_node_group" ]
660b16608fe5b63ccb0c07e1f14d7f05
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a scheduled event rule for each entry in `var.export.events` that triggers a Lambda function every `each.value.schedule`, configure the Lambda target with a JSON input specifying the backup S3 bucket name, an IAM role ARN looked up per event key, a log prefix, and SQS queue options including a 120-second visibil...
resource "aws_cloudwatch_event_rule" "CloudWatchLogsToLogS3EventRule" { for_each = var.export.events name = "CloudWatchLogsToLogS3EventRule_${each.key}" description = "CloudWatchLogsToLogS3EventRule_${each.key}" schedule_expression = each.value.schedule depends_on = [ aws_lambda...
anthunt/aws-logs-export-to-s3
Apache-2.0
root/module-log/CloudWatchLogsToLogS3EventRule.tf
aws
[ "aws_cloudwatch_event_rule", "aws_cloudwatch_event_target", "aws_lambda_permission" ]
32e062248fbf7cb2179b5b32caae71c2
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 service (e.g., `myapp-service-role`) that can be assumed by ECS tasks, and attach a policy to it that grants permission to establish SSM messages control and data channels for all resources.
resource "aws_iam_role" "task_role" { name = format("%s-service-role", var.service_name) assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Principal = { Service = "ecs-tasks.amazonaws.com" } Effect = "Allow" ...
lgabrieldiniz05/terraform-aws-ecs-modules
MIT
task_role.tf
aws
[ "aws_iam_role", "aws_iam_role_policy" ]
efec5f74bd08ad5387205e37be0ef4f9
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an HTTP API named helloWorldAPI in the eu-west-3 region with two Lambda-backed routes: one at GET /x86 invoking a Go 1.x x86_64 Lambda function named helloWorldx86 packaged in hellox86.zip, and another at GET /arm64 invoking a provided.al2 ARM64 Lambda function named helloWorldarm64 packaged in bootstrap.zip; se...
provider "aws" { region = "eu-west-3" } resource "aws_lambda_function" "hello_world_x86" { filename = "hellox86.zip" function_name = "helloWorldx86" architectures = ["x86_64"] role = aws_iam_role.lambda_role.arn handler = "hello" runtime = "go1.x" source_code...
jbleduigou/golang-terraform-lambda-hello-world
Apache-2.0
main.tf
aws
[ "aws_apigatewayv2_api", "aws_apigatewayv2_integration", "aws_apigatewayv2_route", "aws_apigatewayv2_stage", "aws_cloudwatch_log_group", "aws_iam_role", "aws_lambda_function", "aws_lambda_permission" ]
210332934efe352d3c8ce9d7d9139002
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role with a name specified by a variable, configured so that only entities whose STS AssumeRole request includes active MFA authentication can assume it, attach a policy whose file path is provided via a variable, and apply any tags passed in via a variable to both the role and the policy.
resource "aws_iam_role" "this" { name = var.role_name assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [ { Effect = "Allow", Principal = { AWS = var.trusted_entity_arn }, Action = "sts:AssumeRole", Condition = { BoolIfEx...
k4sth4/hipaa-landing-zone
MIT
terraform/modules/iam/main.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
bb0f6c427d4a6a8f27dc139648a791c6
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM user named Peter_NY in the specified AWS region, attach a policy allowing all EC2 describe actions on all resources, generate an access key for this user encrypted with the public key in publicbase64.key, and output both the encrypted secret and the access key ID.
# AWS provider configuration for the specified region provider "aws" { alias = "main" region = var.region # Set the AWS region based on the 'region' variable } # AWS IAM user resource creation resource "aws_iam_user" "username" { name = "Peter_NY" # Specify the IAM user name path = "/" # Set...
bhowmickkrishnendu/AWS-With-Terraform
MIT
IAM_User_and_Policy/main.tf
aws
[ "aws_iam_access_key", "aws_iam_policy", "aws_iam_user", "aws_iam_user_policy_attachment" ]
a4866614f26b5b2282c3d1437b7fda16
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an AWS Amplify app named after the input variable, connected to a specified GitHub repository with OAuth token authentication, auto-building enabled or disabled as configured, and a custom build specification; attach the AWS managed AdministratorAccess-Amplify policy to a new IAM role assumed by the Amplify serv...
resource "aws_iam_role" "amplify" { name = "${var.name}-amplify-role" tags = var.tags assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Effect = "Allow" Principal = { Service = "amplify.amazonaws.com" } ...
ManagedKube/kubernetes-ops
Apache-2.0
terraform-modules/aws/amplify/main.tf
aws
[ "aws_amplify_app", "aws_amplify_branch", "aws_amplify_domain_association", "aws_iam_role", "aws_iam_role_policy_attachment" ]
c0e102686e8e4b5c0c8db9d159cc6501
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 cluster name, and tag it as a shared Kubernetes cluster resource. Provision an equal number of public and private subnets across the specified availability zones, assigning public subnets to launch instances with public IPs and tagging them for extern...
resource "aws_vpc" "main" { cidr_block = var.vpc_cidr enable_dns_hostnames = true enable_dns_support = true tags = { Name = "${var.cluster_name}-vpc" "kubernetes.io/cluster/${var.cluster_name}" = "shared" } } resource "aws_subnet" "private" { ...
anilkumar663/ultimate-devops-project-aws
Apache-2.0
eks-install/modules/vpc/main.tf
aws
[ "aws_eip", "aws_internet_gateway", "aws_nat_gateway", "aws_route_table", "aws_route_table_association", "aws_subnet", "aws_vpc" ]
9679f2b6d731a8517ce053ffd7ddb428
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 a specified AMI, instance type, subnet, security group, and SSH key pair, optionally override the root volume size if provided, and tag the instance with a name combining project, environment, and instance name.
resource "aws_instance" "this" { ami = var.ami instance_type = var.instance_type subnet_id = var.subnet_id vpc_security_group_ids = var.vpc_security_group_ids key_name = var.key_name user_data = var.user_data dynamic "root_block_device" ...
christranv/aws-terrajet
Apache-2.0
modules/ec2/main.tf
aws
[ "aws_instance" ]
6e1cc0731727f3dcc8dea626ef175e58
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named using the environment and API name variables that can be assumed by the Lambda service, attach three policies to it: one granting permissions to manage EC2 network interfaces for VPC access, one allowing the Lambda function to create and write logs to CloudWatch, and one permitting retrieval of...
data "aws_iam_policy_document" "api_lambda_assume_role_policy" { statement { actions = ["sts:AssumeRole"] principals { type = "Service" identifiers = ["lambda.amazonaws.com"] } } } resource "aws_iam_role" "api_lambda_role" { name = "${var.env_name}-${var.api_name}-lam...
ONS-Innovation/keh-prt-api
MIT
terraform/lambda/iam.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
493e3ec9b88ff307d05d5a20293ae467
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an Application Load Balancer named after the deployment variable, fronted by a security group that allows inbound HTTPS from anywhere and all outbound traffic, configure it to listen on port 443 with the ELBSecurityPolicy-2016-08 TLS policy and a validated ACM certificate, route traffic to a target group named a...
resource "aws_security_group" "alb_sg" { name_prefix = "alb-sg-" ingress { description = "HTTPS" from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] ...
NamazuStudios/community-edition-aws
MIT
alb.tf
aws
[ "aws_lb", "aws_lb_listener", "aws_lb_target_group", "aws_lb_target_group_attachment", "aws_security_group" ]
f54a89390efb8b20f724a189760c345a
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 enabled, using a configurable CIDR block and name. Provision private and public subnets within it based on provided subnet lists, attach an internet gateway, and configure a public route table that routes all traffic (0.0.0.0/0) to the internet gateway, associating it with each public subn...
/** * This Terraform configuration file defines the infrastructure resources for a network module. * It creates an AWS VPC, subnets (private and public), an internet gateway, route tables, route table associations, * security groups, and sets up ingress and egress rules. * */ resource "aws_vpc" "vpc" { cidr_bl...
nexomis/tf_tk
Apache-2.0
modules/network/main.tf
aws
[ "aws_internet_gateway", "aws_route_table", "aws_route_table_association", "aws_security_group", "aws_subnet", "aws_vpc", "aws_vpc_endpoint" ]
8a1b57377fe057bec6cff2b446ca6703
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create three network interfaces for an F5 BigIP instance: one management interface attached to the management subnet with a specified private IP, one external interface attached to the external subnet with a specified private IP and an additional secondary IP for VIP usage, and one internal interface attached to the in...
# Management ENI resource "aws_network_interface" "mgmt_eni" { subnet_id = var.subnet_mgmt_id security_groups = var.security_group_ids private_ips = var.private_ip_mgmt != null ? [var.private_ip_mgmt] : [] description = "Mgmt int for F5 BigIP instance" tags = { Name = var.eni_mgmt_name } ...
mshoaibshafi/f5appworld25
Apache-2.0
phase-1/eni.tf
aws
[ "aws_network_interface" ]
88f32b1436d895621808ac6034d385af
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create three groups of subnets within the main VPC: public subnets, private subnets, and database subnets, each group matching the number and availability zones defined in the variables, with CIDR blocks assigned from their respective variable lists, and naming each subnet using the project name, environment, and a cle...
### Public Subnets resource "aws_subnet" "public" { count = length(var.public_subnets) vpc_id = aws_vpc.main.id cidr_block = var.public_subnets[count.index] availability_zone = var.azs[count.index] tags = { Name = format("%s-%s-public-subnet%s", var.project_name, var.environm...
SailerAI/terraform-aws-networking
MIT
subnets.tf
aws
[ "aws_subnet" ]
12ca8c68fbbf9149a33264ae55d9568e
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Lambda function named with a random suffix that processes CloudWatch Logs matching a configurable filter pattern, extracts log fields using a regex and capture group, sends the results to a specified SNS topic, and ensure the function has a 14-day log retention for its own execution logs, a 60-second timeout, ...
locals { function_name = "transform-cloudwatch-log-${random_id.unique_id.dec}" } resource "aws_cloudwatch_log_subscription_filter" "cloudwatch_log_filter" { name = "cloudwatch_log_filter-${random_id.unique_id.dec}" log_group_name = data.aws_cloudwatch_log_group.log_group.name filter_pattern = var...
thoughtbot/flightdeck
MIT
aws/cloudwatch-log-extract/main.tf
aws
[ "aws_cloudwatch_log_group", "aws_cloudwatch_log_subscription_filter", "aws_iam_role", "aws_iam_role_policy", "aws_lambda_function", "aws_lambda_permission", "random_id" ]
5208c9a777e727bf1ec75d8d1f0e10b7
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-up-and-running-state-fss” with versioning enabled, server-side encryption using AES256, and protection against accidental deletion; also create a DynamoDB table named “terraform-up-and-running-locks” with a single string attribute “LockID” as the primary key and on-demand billing to...
# s3 bucket to store our terraform state file remotely resource "aws_s3_bucket" "terraform_state" { bucket = var.bucket_name # "terraform-up-and-running-state-fss" # prevent accidental deleteion of this s3 bucket via terraform lifecycle { prevent_destroy = true } # enable versioning so that we can se...
oulai87/CI-CD-Terraform-GithubActions
MIT
.deploy/terraform/modules/backends/s3/main.tf
aws
[ "aws_dynamodb_table", "aws_s3_bucket" ]
975d6a468ccee1c1ea1936dd64452de9
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a CloudWatch Logs group with a configurable name and retention period to receive CloudTrail event logs, set up an IAM role trusted by CloudTrail that grants permissions to create log streams and write log events to that group, and configure a global, multi-region CloudTrail trail that delivers logs to both the s...
# -------------------------------------------------------------------------------------------------- # CloudWatch Logs group to accept CloudTrail event stream. # -------------------------------------------------------------------------------------------------- resource "aws_cloudwatch_log_group" "cloudtrail_events" { ...
lekkehart/aws-accounts-baseline
MIT
modules/security-baseline/cloudtrail-baseline/main.tf
aws
[ "aws_cloudtrail", "aws_cloudwatch_log_group", "aws_iam_role", "aws_iam_role_policy" ]
09d793054dc4f1d756085e0ed29939ca
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a t3.micro Amazon EC2 instance in the first public subnet of the specified VPC, using the latest Amazon Linux 2023 AMI, with a public IP, attached IAM instance profile named “ec2_instance_profile”, and configure it at boot to install and start nginx, sync image files (jpg, jpeg, png, gif) from the S3 bucket “...
data "aws_ami" "amazon_linux_2023" { most_recent = true owners = ["amazon"] filter { name = "name" values = ["al2023-ami-*-x86_64"] } } resource "aws_iam_instance_profile" "ec2_profile" { name = "ec2_instance_profile" role = var.ec2_service_role.name } resource "aws_instance" "ec2_server" {...
RayVilaca/projeto-galeria-fotos
MIT
modules/compute/ec2.tf
aws
[ "aws_iam_instance_profile", "aws_instance" ]
7e23ab3d2b0c0baf4da0b188cfac2897
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an EC2 instance with a configurable name suffix, using the latest AMI matching specified filters and owned by designated accounts, launched in a given VPC subnet with SSH access restricted to specified CIDR blocks, an IAM instance profile granting SSM access when enabled, and a gp3 root volume that is encrypted ...
locals { name = "${var.name}${var.instance_suffix}" } data "aws_ami" "this" { most_recent = true filter { name = "name" values = var.ami_name_filters } filter { name = "virtualization-type" values = ["hvm"] } owners = var.ami_owners } data "aws_iam_policy_document" "assume" { state...
truemark/terraform-aws-bastion
BSD-3-Clause
main.tf
aws
[ "aws_iam_instance_profile", "aws_iam_role", "aws_iam_role_policy_attachment", "aws_instance", "aws_security_group" ]
8ad34ff2c23677d05d9ac384778f11dd
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 Lambda function with a trailing `-role`, attach a policy granting it permission to assume the Lambda service role, write logs to any CloudWatch log group, and manage backups for a specific DynamoDB table whose ARN is provided via a variable.
# Lambda Role data "aws_iam_policy_document" "lambda_assume_role_policy" { statement { actions = ["sts:AssumeRole"] effect = "Allow" principals { type = "Service" identifiers = ["lambda.amazonaws.com"] } } } data "aws_iam_policy_document" "lambda_policy_doc" { statement { ...
rb-org/tfm-aws-mvdb-dyn-db
MIT
lambda/iam.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
4a925e54e83b0dc2ab94c7d4e26a61bc
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Configure the main ECS cluster to use FARGATE as its only capacity provider and set up a default capacity provider strategy where FARGATE tasks are launched with a base count of 20 and a weight of 50.
resource "aws_ecs_cluster_capacity_providers" "example" { cluster_name = aws_ecs_cluster.main.name capacity_providers = ["FARGATE"] default_capacity_provider_strategy { base = 20 weight = 50 capacity_provider = "FARGATE" } }
AlexandreRosasCosta/project-terraform-test
MIT
Infrastructure/Modules/Services/ECS/capacity-providers.tf
aws
[ "aws_ecs_cluster_capacity_providers" ]
459210eeec8846705dc058c4117c51b0
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Lambda function named using the `name` local value, deployed as a container image from ECR with a version specified by the `image_version` variable, configured to publish a new version on each deployment, with execution role permissions, a timeout and memory size defined by variables, and environment variables...
resource "aws_lambda_function" "lambda" { function_name = local.name role = aws_iam_role.execution_role.arn image_uri = "${local.account_id}.dkr.ecr.${local.region}.amazonaws.com/${var.image_name}:${var.image_version}" package_type = "Image" publish = true timeout = var.function...
mindlapse/terraform_modules
MIT
aws/scheduled_lambda/aws_lambda_function.tf
aws
[ "aws_lambda_function" ]
a4bf853200f129341c907b3b05d553e1
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a KMS key named “Backup Vault CMK” with key rotation enabled, an alias “alias/aws-backup”, and a resource policy that grants full permissions to the account’s root user, while allowing specific Backup-related roles from within the organization to encrypt, decrypt, and manage grants—specifically the AWS Backup se...
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 resource "aws_kms_alias" "backup" { name = "alias/aws-backup" target_key_id = aws_kms_key.backup.key_id } resource "aws_kms_key" "backup" { description = "Backup Vault CMK" enable_key_ro...
awslabs/aft-blueprints
Apache-2.0
modules/backup/central_vault/kms.tf
aws
[ "aws_kms_alias", "aws_kms_key" ]
c06effe970eb818f238750db4e87d199
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named using the value of `var.role_name` that can be assumed by the AWS account specified in `var.central_arn`, and attach to it a policy granting permissions to perform backup-related operations—including creating, copying, and managing EC2 snapshots and volumes, terminating instances tagged for bac...
data "aws_iam_policy_document" "cv_backup" { statement { sid = "DeleteVolumeSnapshot" actions = [ "ec2:DeleteVolume", "ec2:DeleteSnapshot" ] resources = ["*"] condition { test = "StringLike" variable = "ec2:ResourceTag/_GX_BACKUP_" values = ["*"] } } ...
kelyn-technologies/terraform-aws-commvault-iam
Apache-2.0
modules/commvault-tenant-backup-role/main.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
c8f383cd6300e74ef5253347e55ca574
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an EC2 instance of type t2.micro using AMI ami-0c7b4941f0f in the default VPC, named Dynamic-Ports-Lab, and configure its security group to allow inbound TCP traffic on ports 80 and 443 from any IPv4 address, and outbound TCP traffic on ports 443 and 1433 to any IPv4 address.
## This lab is already complete. You don't need to do anything other than `terraform init` and `terraform apply`. ## Review the dynamic block code and how it interacts with the locals block. ## > Note that labs such as these will require a default VPC and subnet (as usual). resource "aws_instance" "dynamic_ports" { ...
Chinnydev/tac-course
MIT
lesson-13/dynamic-blocks/main.tf
aws
[ "aws_instance", "aws_security_group" ]
c55c55f865d8d175ea35950bc93f2a52
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named using the environment and role name variables, with a description provided via a variable, that allows the specified trusted principal service to assume it using the STS AssumeRole action, attach a variable number of managed policies to it based on a list of ARNs, and tag it with the environmen...
resource "aws_iam_role" "role" { name = "${var.environment}-${var.role_name}" description = var.role_description assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Principal = { Service = var.trusted_principal } ...
mistwire/90-days-of-terraform
MIT
08-modules/03/modules/iam_role/main.tf
aws
[ "aws_iam_role", "aws_iam_role_policy_attachment" ]
df79c0a9be414d9fe742bf491cf9f566
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an Application Load Balancer named with the project name and environment, exposed to the internet, using specified security groups and subnets, with deletion protection disabled; set up a target group on port 80 using HTTP protocol in the given VPC, configured to health-check targets at a configurable path every...
resource "aws_lb" "main" { name = "${var.name}-alb-${var.environment}" internal = false load_balancer_type = "application" security_groups = var.alb_security_groups subnets = var.subnets.*.id enable_deletion_protection = false tags = { Name = "${var.name}...
CiscoDevNet/appdynamics-terraform-ecs-fargate
Apache-2.0
alb/alb-main.tf
aws
[ "aws_alb_listener", "aws_alb_target_group", "aws_lb" ]
9012dcf88aa4f13905a39f8736370716
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named `aws-load-balancer-controller-role` in the EKS cluster’s account, trust the Kubernetes service account `aws-load-balancer-controller` in the `kube-system` namespace via OIDC federation, and attach a policy granting permissions to provision and manage AWS Application and Network Load Balancers, ...
locals { iam_policy = jsonencode({ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iam:CreateServiceLinkedRole" ], "Resource": "*", "Condition": { "StringEquals": { "iam:AWSServiceName": "elasticloadbalanci...
levgorbunov1/my-eks-cluster
MIT
hosting-infra/load-balancer-controller.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
4932d9094fdb511d34f82b5b229472cf
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named according to the `bucket_name` variable, configure it to serve a static website with `index.html` as the index document and `error.html` as the error page, upload `index.html` and `error.html` from specified file paths with `text/html` content type, upload all image assets (jpg, png, webp, gif...
# 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 tags = { UserUuid = v...
emmanuelkaringi/TerraTowns
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" ]
8bf699b3e0a302a98401cb487efc1a6b
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 provided via a variable, configure it to send notifications to a specific SQS queue whenever any object is created (with no prefix or suffix filtering), and attach a bucket policy that grants the Amazon Transcribe service permission to read all objects in the bucket.
resource "aws_s3_bucket" "bucket" { bucket = var.bucket_name } resource "aws_s3_bucket_notification" "notification" { bucket = aws_s3_bucket.bucket.id queue { queue_arn = var.sqs_queue_arn events = ["s3:ObjectCreated:*"] filter_prefix = "" filter_suffix = "" } depends_on = [aws_s...
tapanhegde26/summarAIzer
Apache-2.0
IaC/modules/s3_upload_bucket/main.tf
aws
[ "aws_s3_bucket", "aws_s3_bucket_notification", "aws_s3_bucket_policy" ]
ec0e1adf5d2e1a404591030b758f890c
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Kinesis stream with a configurable name, retention period, and stream mode, enable shard-level metrics, and tag it with a Name equal to the stream’s name.
# Kinesis Stream resource "aws_kinesis_stream" "stream" { name = var.name retention_period = var.retention_period shard_level_metrics = var.shard_level_metrics stream_mode_details { stream_mode = var.stream_mode } tags = { Name = var.name } }
mmdcloud/aws-iot-core-timestream
Apache-2.0
terraform/modules/kinesis/main.tf
aws
[ "aws_kinesis_stream" ]
581330ba9041c8b73bd3f82929f677fa
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, spanning as many availability zones as available and matching the number of public subnet CIDRs provided, with public subnets that launch instances with public IPs and are tagged for Kubernetes load balancer use, and private subnets tagged for internal load balancer and Karpenter ...
# Data data "aws_availability_zones" "available" { state = "available" filter { name = "opt-in-status" values = ["opt-in-not-required"] } } locals { azs_count = min(length(data.aws_availability_zones.available.names), length(var.public_subnets_cidr_block)) azs = slice(data.aws_availability_zo...
Davideagle10/aws-eks-observability-iac
Apache-2.0
terraform/modules/networking/main.tf
aws
[ "aws_eip", "aws_internet_gateway", "aws_nat_gateway", "aws_route_table", "aws_route_table_association", "aws_subnet", "aws_vpc" ]
88a2a7129333aa485ce20e110d5d925d
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create three CNAME records in the specified Route 53 zone pointing to sendgrid.net for the domains named in `var.id_01`, `var.id_02`, and `var.id_03`, where the third uses a subdomain of `sendgrid.net` derived from `var.value_03`; set up two DKIM CNAME records under `_domainkey` using the SendGrid verification IDs `var...
resource "aws_route53_record" "s01" { count = var.id_01 != "" ? 1 : 0 zone_id = var.zone name = var.id_01 type = "CNAME" ttl = var.ttl records = ["sendgrid.net"] } resource "aws_route53_record" "s02" { count = var.id_02 != "" ? 1 : 0 zone_id = var.zone name = var.id_02 type = "CN...
genstackio/terraform-aws-dns
MIT
modules/sendgrid/main.tf
aws
[ "aws_route53_record" ]
fa2f171454a5fc6ce3d9f4a47f6af6ae
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named using the provided name or defaulting to `<name>-eks-node-group`, allowing EC2 instances to assume it, attach the standard AWS managed policies for EKS worker nodes, ECR read-only access, CNI, EBS CSI, and EFS CSI, plus any additional policies passed in, and optionally attach a custom inline po...
locals { iam_role_name = coalesce(var.iam_role_name, "${var.name}-eks-node-group") iam_role_policy_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy" iam_role_policies = { eks_worker_node_policy = "${local.iam_role_policy_prefix}/AmazonEKSWorkerNodePolicy" ec...
c0x12c/terraform-aws-eks-managed-node-group
Apache-2.0
iam.tf
aws
[ "aws_iam_role", "aws_iam_role_policy", "aws_iam_role_policy_attachment" ]
acd0a46607f1e2d5da00c80335d61d72
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Lambda function named using the second entry in `lf_function_names`, packaged from `../../lambda_functions/lf2/lf2.zip`, running Python 3.11 with a 15-second timeout, using an IAM role named `lf2_role` that grants basic execution, full SQS access, and assumes the Lambda service; install dependencies from `requ...
variable "lf2_root" { default = "../../lambda_functions/lf2" } resource "aws_iam_role" "lf2_role" { name = "lf2_role" # configured in opensearch's access_policies assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [{ Action = "sts:AssumeRole" Effect = "Allow" Sid = ...
nicksome168/aws-ai-chatflow
MIT
terraform/lambda/lf2.tf
aws
[ "aws_iam_role", "aws_iam_role_policy_attachment", "aws_lambda_function", "null_resource" ]
38e38dff7d08222abed76516473bb9fb
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an S3 bucket named `fictional-octo-system-cloudtrail-<account-id>` to store CloudTrail logs with versioning enabled, AES-256 encryption, full public access blocking, and a 30-day retention policy that deletes both current and noncurrent versions; configure a bucket policy granting CloudTrail write access to `AWS...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { region = var.aws_region default_tags { tags = { Environment = var.environment ManagedBy = "Terraform" Module = "cloudtrail-organization" Purpose = "Audit-Logging" ...
KuduWorks/fictional-octo-system
MIT
deployments/aws/management/cloudtrail-organization/main.tf
aws
[ "aws_cloudtrail", "aws_s3_bucket", "aws_s3_bucket_lifecycle_configuration", "aws_s3_bucket_policy", "aws_s3_bucket_public_access_block", "aws_s3_bucket_server_side_encryption_configuration", "aws_s3_bucket_versioning" ]
ca11922dab60dadbec3177a2080cb825
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an AWS Amplify app named “hello-static-site” that pulls code from the GitHub repository `https://github.com/Falltrades/cloud-example` using a personal access token, assigns it an IAM service role for building, and configures it to build a static site from the `static-website/aws-amplify/website` subdirectory wit...
resource "aws_amplify_app" "static_site" { name = "hello-static-site" repository = "https://github.com/Falltrades/cloud-example" access_token = var.personal_access_token iam_service_role_arn = aws_iam_role.amplify_build_role.arn # Required even for static sites build_spec ...
Falltrades/cloud-example
MIT
static-website/aws-amplify/terraform/main.tf
aws
[ "aws_amplify_app", "aws_amplify_branch" ]
f69582e787fb74e0abe99d001d1e42ec
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role for the Karpenter controller with a name based on the cluster name, attach a policy granting permissions to launch and terminate EC2 instances (restricted by a specific tag key-value pair), describe resources, run instances with required resources, read SSM parameters, describe the EKS cluster, pass ...
data "aws_partition" "current" {} data "aws_caller_identity" "current" {} locals { account_id = data.aws_caller_identity.current.account_id partition = data.aws_partition.current.partition dns_suffix = data.aws_partition.current.dns_suffix } #####################################################################...
omototo/terraform-eks-karpenter
Apache-2.0
modules/karpenter/main.tf
aws
[ "aws_cloudwatch_event_rule", "aws_cloudwatch_event_target", "aws_iam_instance_profile", "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment", "aws_sqs_queue", "aws_sqs_queue_policy" ]
e320a55b54292aff90733ac04569c1ea
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision two Ubuntu 22.04 EC2 instances and two Nginx 1.25.4 EC2 instances, each using the most recent AMI from Canonical and Bitnami respectively, with instance types and subnets specified via input variables, and tag them with the project name and index or key.
locals { ami_ids = { ubuntu = data.aws_ami.ubuntu.id nginx = data.aws_ami.nginx.id } } data "aws_ami" "ubuntu" { most_recent = true owners = ["099720109477"] # Owner is Canonical # filter by name filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-*-22.04-amd64-server-*...
Rurutia1027/DevOPs-Playground
MIT
practice-terraform/scripts/11-multiple-resources/exercise-34/compute.tf
aws
[ "aws_instance" ]
b0c8e4f03f14be780f80dd3844bf1a54
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 enabled, named using the provided `name` variable, and configure it with public, private, and Transit Gateway subnets across the specified availability zones—using either custom CIDR blocks or calculated subnets from the base `vpc_sub` value—along with one NAT gateway and one internet ga...
terraform { } resource "aws_vpc" "default" { cidr_block = ( var.vpc_cidr == null ? format("%s.0.0/16", var.vpc_sub) : var.vpc_cidr ) enable_dns_hostnames = true tags = { Name = "${var.name}-vpc" Description = "VPC for ${var.name}" } } /* Public Subnet */ resource "aws_subnet" "p...
ModuStack/terraform-modules
Apache-2.0
aws/network/main.tf
aws
[ "aws_ec2_transit_gateway_vpc_attachment", "aws_eip", "aws_internet_gateway", "aws_nat_gateway", "aws_route_table_association", "aws_subnet", "aws_vpc" ]
b093547f99aa68dd582b6ecada18119d
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a VPC named roberts_vpc with a 10.0.0.0/16 CIDR block, attach an internet gateway to it, provision two public subnets—one in eu-north-1a (10.0.1.0/24) and one in eu-north-1b (10.0.2.0/24)—each configured to automatically assign public IP addresses to new instances, and associate both subnets with a single route ...
resource "aws_vpc" "roberts_vpc" { cidr_block = "10.0.0.0/16" } resource "aws_internet_gateway" "roberts_gateway" { vpc_id = aws_vpc.roberts_vpc.id } resource "aws_subnet" "subnet_logger2_api" { vpc_id = aws_vpc.roberts_vpc.id cidr_block = "10.0.1.0/24" availability_zone ...
Robert076/logger2
MIT
terraform/vpc.tf
aws
[ "aws_internet_gateway", "aws_route_table", "aws_route_table_association", "aws_subnet", "aws_vpc" ]
9584354f3e3c7c34c1617026a434d32d
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a ZIP archive from the file `code/lambda_function.py` in the module’s directory and use it as the deployment package for a Lambda function named `stopEC2Instances` that runs Python 3.8, executes the `lambda_handler` function, and is authorized by the `lambda_execution_role` IAM role.
data "archive_file" "python_lambda_package" { type = "zip" source_file = "${path.module}/code/lambda_function.py" output_path = "lambda_function.zip" } resource "aws_lambda_function" "stop_ec2_instances" { function_name = "stopEC2Instances" filename = "lambda_function.zip" source_code_hash = data...
devopsbyday/ec2-instance-scheduler
MIT
schedule/lambda.tf
aws
[ "aws_lambda_function" ]
030344f23d5b898ae270e4c6ebe232db
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create two private subnets in the eu-west-3 region, one in availability zone eu-west-3a with CIDR 10.0.3.0/24 and another in eu-west-3b with CIDR 10.0.4.0/24, tag them with a shared Kubernetes cluster name and internal ELB role, and associate each subnet with its own private route table that routes traffic for a specif...
resource "aws_subnet" "private" { count = 2 vpc_id = aws_vpc.vpc.id cidr_block = count.index == 0 ? "10.0.3.0/24" : "10.0.4.0/24" availability_zone = count.index == 0 ? "eu-west-3a" : "eu-west-3b" tags = { Name = "private-subnet-${count.index + 1}" "kubernetes.io/cluster/${var....
lmdevops/eks-devops-platform-template
MIT
terraform/modules/network/private-subnets.tf
aws
[ "aws_route_table", "aws_route_table_association", "aws_subnet" ]
37bc3acdd0a67e81fe934e8c48b23f5e
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a scheduled scaling action that scales up an AWS service (such as an ECS service or Auto Scaling group) at a configurable time on weekdays in the America/Sao_Paulo timezone, setting a specific minimum and maximum capacity, and another scheduled action that scales down at a different configurable weekday time wit...
resource "aws_appautoscaling_scheduled_action" "scale_up" { count = var.enable_schedule ? 1 : 0 name = "up_schedule-up" service_namespace = aws_appautoscaling_target.this[0].service_namespace resource_id = aws_appautoscaling_target.this[0].resource_id scalable_dimension...
rafaelfernandessilva/ecs-workload-laboratorio
MIT
modules/ecs_service_autoscaling/auto_scaling_schedule.tf
aws
[ "aws_appautoscaling_scheduled_action" ]
e5674cfa6254fc9cf11b6d1bfb9e8f9b
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an Application Load Balancer with configurable name, internal or internet-facing deployment, security groups, subnets, and advanced settings like HTTP/2, cross-zone load balancing, deletion protection, idle timeout, and optional access logging to an S3 bucket; provision one or more target groups with customizabl...
resource "aws_lb" "this" { count = var.create_lb ? 1 : 0 name = var.name name_prefix = var.name_prefix load_balancer_type = var.load_balancer_type internal = var.internal security_groups = var.security_groups subnets = var.subnets idle_timeout = var....
uts-itd/tf-module-aws-alb
Apache-2.0
main.tf
aws
[ "aws_lb", "aws_lb_listener", "aws_lb_listener_certificate", "aws_lb_listener_rule", "aws_lb_target_group", "aws_lb_target_group_attachment" ]
2302993ea178226aa55f7c90c25cba3c
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an SNS topic named via a variable, encrypted with a KMS key only if encryption is enabled, and attach a policy that permits publishing from specific AWS account IDs and from EventBridge.
resource "aws_sns_topic" "default" { count = var.sns_topic_name != "" ? 1 : 0 name = var.sns_topic_name kms_master_key_id = var.sns_kms_encryption ? aws_kms_key.sns[0].id : null # default key does not allow cloudwatch alarms to publish # provisioner "local-exec" { # command = "aws s...
DNXLabs/terraform-aws-sns
Apache-2.0
sns-topic.tf
aws
[ "aws_sns_topic", "aws_sns_topic_policy" ]
0cecf43927b76fe3ac22a535a3818d3d
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an Elasticsearch domain named parking-sensor in the ap-southeast-2 region using version 7.7, with a single t3.small.elasticsearch instance, 10 GB of EBS storage, no dedicated master nodes, no zone awareness, explicit index operations enabled, and automated snapshots scheduled to start at 23:00 UTC.
terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { region = "ap-southeast-2" } variable "domain" { default = "parking-sensor" } data "aws_region" "current" {} resource "aws_elasticsearch_domain" "es" { domain_name = var.domain elasticsearch_...
wangyunlongau/parking-sensor-search-engine
MIT
es-config.tf
aws
[ "aws_elasticsearch_domain" ]
5b51b7a55bac4f0efa58249e96081de1
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a single Amazon Linux 2 EC2 instance named “web-server” in the specified region, using the latest Amazon Linux 2 AMI, with an instance type defined by a variable, and attach a security group that allows SSH access only from CIDR blocks specified in a variable, unrestricted HTTP access, and full outbound inter...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { region = var.aws_region } # Fetch latest Amazon Linux 2 AMI data "aws_ami" "amazon_linux" { most_recent = true owners = ["amazon"] filter { name = "name" values = ["amzn2-ami-hvm-*-x86_6...
saideep2000/Terraform
Apache-2.0
03-ec2-instance/main.tf
aws
[ "aws_instance", "aws_key_pair", "aws_security_group" ]
e6f7133f5a78370f866c3b87663d9592
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named `<app_name>-asg-backend-lb-access-sg` that allows inbound HTTP traffic on port 80 only from another security group named `<app_name>-asg-web-access-sg`, permits all outbound traffic to any IPv4 or IPv6 address, and sets a 3-minute deletion timeout. Separately, create a security group named...
# Backend server Load Balancer ASG access security group resource "aws_security_group" "asg_backend_lb_access_sg" { name = "${var.app_name}-asg-backend-lb-access-sg" description = "Allow http traffic from ASG-BACKEND-LB" vpc_id = aws_vpc.vpc.id # allow http 80 port ingress { description =...
ErenSalman/midas-case
Apache-2.0
security_groups_backend.tf
aws
[ "aws_security_group" ]
00d32d778350109b759bd468709d0711
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM group named after the `maintainers` variable and attach the AWS managed policy `AWSServiceCatalogEndUserFullAccess` to it so that members of the group have full access to AWS Service Catalog as end users.
resource "aws_iam_group" "catalog_maintainer" { name = var.maintainers } resource "aws_iam_group_policy_attachment" "maintainer" { group = aws_iam_group.catalog_readers.name policy_arn = "arn:aws:iam::aws:policy/AWSServiceCatalogEndUserFullAccess" } //aws iam list-policies --query 'Policies[?PolicyName==`...
JamesWoolfenden/terraform-aws-servicecatalog
Apache-2.0
aws_iam_group.catalog_maintainer.tf
aws
[ "aws_iam_group", "aws_iam_group_policy_attachment" ]
08eaf7124b6d832ed2f379ac321b31fd
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an EKS cluster named after the project with Kubernetes version 1.31, configured with private and public access endpoints, using the specified public subnets for the control plane, and ensure it depends on the cluster role’s policy attachment.
resource "aws_eks_cluster" "eks_cluster" { name = "${var.project_name}-cluster" role_arn = aws_iam_role.eks_cluster_role.arn version = "1.31" vpc_config { subnet_ids = [ var.public_subnet_1a, var.public_subnet_1b, ] endpoint_private_access = true endpoint_public_access = true ...
igorsrs2019/terraform-eks
MIT
modules/cluster/cluster.tf
aws
[ "aws_eks_cluster" ]
1978f0d30f71ea842a8976ef35dede12
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a VPC with CIDR 172.20.0.0/16, an internet gateway attached to it, and a single subnet in the specified availability zone with CIDR 172.20.0.0/24, routing all internet-bound traffic through the gateway. Launch a t2.micro EC2 instance using AMI ami-08ca3fed11864d6bb in that subnet with a public IP, secured by a k...
terraform { required_providers { aws = { source = "hashicorp/aws" } } backend "s3" { bucket = "next-level-cxt-tfstate" key = "lab-11-tfstate" region = "eu-west-1" profile = "cxt" } } provider "aws" { profile = "cxt" region = "eu-west-1" } # # Variables # variable "...
jorgeteixe/next-level-CXT
MIT
11-ticket-management/10-terraform/main.tf
aws
[ "aws_instance", "aws_internet_gateway", "aws_key_pair", "aws_route53_record", "aws_route_table", "aws_route_table_association", "aws_security_group", "aws_subnet", "aws_vpc" ]
0557e5c092b1780c895b591d7fccfba0
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a VPC with a /16 CIDR block named “MyVpc”, a single public subnet in us-east-1a with a /24 CIDR block that auto-assigns public IPs, an internet gateway attached to the VPC, a route table for the VPC that routes all traffic (0.0.0.0/0) to the internet gateway, associate the subnet with that route table, and a sec...
resource "aws_vpc" "MyVpc" { cidr_block = "10.0.0.0/16" tags = { Name = "MyVpc" } } resource "aws_subnet" "MySubnet" { vpc_id = aws_vpc.MyVpc.id cidr_block = "10.0.1.0/24" availability_zone = "us-east-1a" map_public_ip_on_launch = true tags = { Name = "MySubn...
Aadi-Sonwane/Terraform40Days
MIT
terraInOneshot/provisioners/vpc.tf
aws
[ "aws_internet_gateway", "aws_route_table", "aws_route_table_association", "aws_security_group", "aws_subnet", "aws_vpc" ]
4e75bfb77834c0fecf495c448600c23c
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 db3tierproject using version 8.0, sized as a db.t3.micro with 10 GB storage, deployed across multiple Availability Zones, configured with credentials from variables, placed in a subnet group spanning private-subnet-3 and private-subnet-4, and associated with a specific VPC securit...
resource "aws_db_subnet_group" "db_sub" { name = "db-subnet-group" subnet_ids = [aws_subnet.private-subnet-3.id, aws_subnet.private-subnet-4.id] } resource "aws_db_instance" "default" { allocated_storage = 10 db_name = "db3tierproject" engine = "mysql" engine_versi...
Sakshamtyagi111/terraform-project-3-tier-architecture-deployment
Apache-2.0
database.tf
aws
[ "aws_db_instance", "aws_db_subnet_group" ]
d59159f99e3ae4136ff4a57709fde1c3
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Configure an S3 bucket to trigger a specific Lambda function whenever new objects are created in a designated prefix, ensuring the Lambda has explicit permission to be invoked by S3.
resource "aws_lambda_permission" "allow_bucket_access" { statement_id = "AllowExecutionFromS3Bucket" action = "lambda:InvokeFunction" function_name = var.lambda_arn principal = "s3.amazonaws.com" source_arn = "arn:aws:s3:::${var.bucket_id}" } resource "aws_s3_bucket_notification" "bucket_notif...
dfds-frontend/terraform-modules
MIT
aws/s3-bucket-notification-lambda/main.tf
aws
[ "aws_lambda_permission", "aws_s3_bucket_notification" ]
40ea8e0deb175994e02750aec983f4cc
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named ReadOnlyAuditRole that can be assumed by the AWS account specified in the aquia_account_id variable, attach the AWS managed SecurityAudit policy to it, and ensure it includes a tag with the key “tag-key” and value “tag-value” (to be updated as needed).
provider "aws" { region = var.aws_region } # Create the IAM role resource "aws_iam_role" "readonly_audit_role" { name = "ReadOnlyAuditRole" assume_role_policy = jsonencode({ Version: "2012-10-17", Statement: [ { Effect: "Allow", Principal: { "AWS": "arn:aws:iam::${var.a...
aquia-inc/Z2F-Audit-Role
MIT
terraform/main.tf
aws
[ "aws_iam_policy_attachment", "aws_iam_role" ]
86ccde5cac96030a918ce443c9fc7a5e
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named after the project with the suffix `-cluster-role` that the EKS service can assume, and attach the AWS managed policy `AmazonEKSClusterPolicy` to grant it the necessary permissions for managing an EKS cluster.
# criando role para o cluster resource "aws_iam_role" "eks_cluster_role" { name = "${var.project_name}-cluster-role" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Effect = "Allow" Sid = "" Principal = { ...
jairowmd/terraform-eks
MIT
module/cluster/iam.tf
aws
[ "aws_iam_role", "aws_iam_role_policy_attachment" ]
f524fb3db9852c85517a09093e23a424
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group per entry in the `security_groups` variable, each associated with the specified VPC and named using the project, module, and environment prefix; for each ingress rule in `sg_rules_ingress`, add a rule allowing traffic from the given source security group (or CIDR block) to the specified ports an...
locals { prefix = "${var.project_name}-${var.module_name}-${var.environment}" } resource "aws_security_group" "default" { for_each = { for o in var.security_groups : o.name => o } description = each.value.description vpc_id = var.vpc_id tags = merge(var.default_tags, { Name = "${local.prefix}-${eac...
finddx/seq-treat-tbkb-terraform-modules
MIT
security-groups/main.tf
aws
[ "aws_security_group", "aws_vpc_security_group_egress_rule", "aws_vpc_security_group_ingress_rule" ]
3d2ff50fe5f2c8e963f282cced86be63
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, an Internet Gateway attached to it, and two sets of subnets—public subnets that receive public IP addresses on launch and private subnets that do not—each spanning the number of availability zones specified, with the public subnets associated with a route table that ...
terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { region = var.aws_region } # Create VPC resource "aws_vpc" "main" { cidr_block = var.vpc_cidr enable_dns_support = true enable_dns_hostnames = true tags = { Name = "${var.projec...
saideep2000/Terraform
Apache-2.0
02-basic-vpc/main.tf
aws
[ "aws_internet_gateway", "aws_route_table", "aws_route_table_association", "aws_subnet", "aws_vpc" ]
54a0555144f21c05ea6eba5682fe190d
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create scheduled scaling actions for Auto Scaling groups based on a map of schedule definitions, where each schedule can apply to multiple groups, and for each combination generate a uniquely named scheduled action with configurable min, max, and desired capacity, start/end times, recurrence pattern, and time zone.
locals { autoscaling_schedules_list = flatten([ for schedule_name, v in var.autoscaling_schedules_map : [ for asg in v.autoscaling_group_name_list : { "${asg}_${schedule_name}" = merge(v, { scheduled_action_name = coalesce(v.scheduled_action_name, schedule_name), autoscaling_group_name = asg }) } ] ])...
dmitriy-lukyanchikov/example-aws-kubernetes-app-infra
MIT
modules/aws_autoscaling_schedule/main.tf
aws
[ "aws_autoscaling_schedule" ]
7a88ce10a8334fdde4d4a5c1d269de45
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 domain specified in `var.domain-name`, using DNS validation and including the same domain as a subject alternative name, with lifecycle configured to create before destroy; then validate the certificate using the DNS validation records generated for it.
# ACM certificate resource with the domain name and DNS validation method, supporting subject alternative names resource "aws_acm_certificate" "cert" { provider = aws.use_default_region domain_name = var.domain-name validation_method = "DNS" subject_alternative_names = [var.domain-name] ...
joelwembo/terraform-multi-cloud-provisions
Apache-2.0
terraform-aws-1/Non-Modularized/S3-Static-Website/certificate.tf
aws
[ "aws_acm_certificate", "aws_acm_certificate_validation" ]
74ab100daf718ba486e9a5b9d1e99385
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 primary domain specified in the `certificate_primary` variable, including any additional domains listed in the `certificate_sans` variable, using DNS validation and ensuring the certificate is created before any existing one is destroyed. Output the DNS validation records needed to co...
resource "aws_acm_certificate" "wildcard" { domain_name = var.certificate_primary subject_alternative_names = var.certificate_sans validation_method = "DNS" lifecycle { create_before_destroy = true } } output "dns_validation_records" { value = [ for dvo in aws_acm_certificate...
MAZY-Tech/mazy-video-tools-infra
Apache-2.0
terraform/certifcate.tf
aws
[ "aws_acm_certificate" ]
cfeff0912df36b0a7f541af7ff5b1eb7
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an EC2 instance named “nw-social-visualization-<environment>” using AMI ami-0b5eea76982371e91, with a 4096-bit RSA SSH key pair generated and stored locally as a .pem file, running a user data script that configures a visualization service (e.g., Kibana or Grafana) using a provided Elasticsearch endpoint and env...
resource "tls_private_key" "ssh_private_key" { algorithm = "RSA" rsa_bits = 4096 } resource "aws_key_pair" "ssh_key" { key_name = var.pem_key_name public_key = tls_private_key.ssh_private_key.public_key_openssh provisioner "local-exec" { # This will create the pem where the terraform will run!! command...
Ketan-Joshi/terraform-aws-visualization
Apache-2.0
main.tf
aws
[ "aws_iam_instance_profile", "aws_iam_policy", "aws_iam_policy_attachment", "aws_iam_role", "aws_iam_role_policy_attachment", "aws_instance", "aws_key_pair", "aws_security_group", "tls_private_key" ]
f21136a4868f8929618d373a797ea614
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, tag it as “subnet” and owned by Robert de Bock, then create a security group named “subnet” that allows inbound SSH (port 22) and ICMP traffic from anywhere, and permits all outbound traffic to anywhere. Launch a single subnet in a randomly selected available availability zon...
resource "aws_vpc" "default" { cidr_block = "10.0.0.0/16" tags = { Name = "subnet" owner = "Robert de Bock" } } resource "aws_security_group" "default" { name = "subnet" description = "Allow traffic." vpc_id = aws_vpc.default.id tags = { Name = "subnet" owner = "Ro...
robertdebock/terraform-aws-instance
Apache-2.0
examples/subnet/prerequisites/main.tf
aws
[ "aws_internet_gateway", "aws_route", "aws_route_table", "aws_route_table_association", "aws_security_group", "aws_security_group_rule", "aws_subnet", "aws_vpc", "random_shuffle" ]
c2b27d2e2db833b1cfba21189f870d51
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Redis 7-compatible ElastiCache replication group named after the application with automatic failover enabled, using a specified number of cache clusters, private subnets, and security group; optionally enable at-rest encryption with a provided KMS key ARN.
terraform { required_providers { aws = { source = "hashicorp/aws" } } } resource "aws_elasticache_subnet_group" "default" { name = "${var.app_name}-cache-subnet" subnet_ids = var.private_subnet_ids } resource "aws_elasticache_parameter_group" "default" { name = "cache-params" famil...
1nval1dctf/terraform-aws-ctfd
MIT
modules/elasticache/main.tf
aws
[ "aws_elasticache_parameter_group", "aws_elasticache_replication_group", "aws_elasticache_subnet_group" ]
856836016810510cd9b8a4a836d7f45f
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM password policy requiring at least six characters, lowercase, uppercase, numbers, and symbols, with users allowed to change their own passwords; create an Administrators group in the /administrators/ path and attach the AdministratorAccess managed policy to it; create a user named cli with tags for organi...
provider "aws" { region = var.region profile = var.profile } # Get current user (the managed user using OrganizationAccountAccessRole) data "aws_caller_identity" "current" {} # set a strict password policy resource "aws_iam_account_password_policy" "strict" { minimum_password_length = 6 require_lowercase_char...
rbadillap/aws-account-setup
MIT
main.tf
aws
[ "aws_iam_access_key", "aws_iam_account_password_policy", "aws_iam_group", "aws_iam_group_policy_attachment", "aws_iam_user", "aws_iam_user_group_membership", "aws_s3_bucket", "aws_s3_bucket_object", "aws_s3_bucket_policy" ]
99a18a18fdab0f372bc121601e3326b6
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a single Neptune cluster instance with the specified cluster identifier, instance identifier, and instance class, configured to run on the given port, optionally accessible from the public internet, associated with the provided Neptune subnet group and parameter group, and set to automatically apply minor versio...
resource "aws_neptune_cluster_instance" "this" { cluster_identifier = var.cluster_identifier identifier = var.identifier instance_class = var.class port = var.port publicly_accessible = var.publicly_accessible neptune_subnet_group_na...
imperva/terraform-dsfhub-agentless-onboarding
MIT
modules/aws-neptune-instance/main.tf
aws
[ "aws_neptune_cluster_instance" ]
63f54a16054276d9b169727410a77bb3
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an AWS AppConfig application with a configurable name, description, and tags. For each entry in the environments variable, provision an environment under that application with its name, description, and tags, defaulting the name to the key if not explicitly provided. For each entry in the configuration_profiles ...
resource "aws_appconfig_application" "this" { name = var.name description = var.description tags = var.tags } resource "aws_appconfig_environment" "this" { for_each = var.environments name = coalesce(try(each.value.name, null), each.key) description = try(each.value.description, null) ap...
Catalyst-Consulting-Group/terraform-aws-appconfig
MIT
main.tf
aws
[ "aws_appconfig_application", "aws_appconfig_configuration_profile", "aws_appconfig_environment" ]
868b6cfb54b1b54c49ba98fa9d6b324d
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-northeast-1a Availability Zone with IPv4 and IPv6 support, including a single public subnet that auto-assigns public and IPv6 addresses and enables DNS hostnames for instances; attach an internet gateway and configure a custom route table with default IPv4 and IPv6 routes to the internet gateway,...
terraform { backend "local" { path = ".cache/terraform.tfstate" } required_providers { aws = { source = "hashicorp/aws" } } } variable "aws_profile_name" { type = string default = "develop" } provider "aws" { profile = var.aws_profile_name } resource "aws_vpc" "main" { cidr_...
koshian2/terraform-aws-book
MIT
sample_codes/cp09_vpc_basics/061_EC2/main.tf
aws
[ "aws_instance", "aws_internet_gateway", "aws_route_table", "aws_route_table_association", "aws_security_group", "aws_subnet", "aws_vpc", "aws_vpc_security_group_egress_rule", "aws_vpc_security_group_ingress_rule" ]
1e1b26ec4c6afd127464395994f3bdbb
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Provision a Dell NetWorker Virtual Edition instance using an AMI matching the pattern `DELL_NetWorker_Virtual_Edition_<version>*` owned by AWS account 679593333241, with instance type, EBS data volume count, and volume size determined by the selected size tier (small, medium, or large), attaching a single EBS volume of...
locals { nve_size = { "small" = { nve_data_volume_count = 1 nve_disksize = 600 instance_type = "m5.xlarge" } "medium" = { nve_data_volume_count = 1 nve_disksize = 1200 instance_type = "m5.xlarge" } "large" = { nve_data_vol...
bottkars/terraforming-dps
MIT
terraforming-aws/modules/nve/nve.tf
aws
[ "aws_ebs_volume", "aws_instance", "aws_volume_attachment" ]
c342b88d28068dc4038545e6e083f9ef
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a security group named “SCHEMA” in the specified VPC that allows inbound TCP traffic on ports 9092 through 9096 from the VPC’s CIDR block for broker protocols, permits SSH access on port 22 only from bastion hosts, and allows ICMP echo requests (ping) from the specified allowed IP ranges, the security group itse...
resource "aws_security_group" "schema" { name = "SCHEMA" description = "schema - Managed by Terraform" vpc_id = var.vpc_id # 9092-9095 for all broker protocols ingress { description = "Allow broker protocols" from_port = 9092 to_port = 9096 protocol = "TCP" cidr_block...
JamesWoolfenden/terraform-aws-confluent
Apache-2.0
aws_security_group.schema_registry.tf
aws
[ "aws_security_group" ]
405cdb2b85261d0c24b6585f478850c5
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Associate a Service Catalog product with a portfolio in the specified region, using the provided portfolio and product IDs, with configurable timeout values for create, read, and delete operations.
resource "aws_servicecatalog_product_portfolio_association" "this" { portfolio_id = var.portfolio_id product_id = var.product_id region = var.region accept_language = var.accept_language source_portfolio_id = var.source_portfolio_id timeouts { create = var.timeouts.crea...
ebogdum/terraform-providers
MIT
aws/resources/servicecatalog_product_portfolio_association/main.tf
aws
[ "aws_servicecatalog_product_portfolio_association" ]
6ae8371d9c60ae183a45f381bad4ad08
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Assign the existing AWS SSO admin group to the admin permission set in every account listed in `local.target_accounts`, using the specified SSO instance ARN and group ID.
resource "aws_ssoadmin_account_assignment" "admin_group_everywhere" { for_each = local.target_accounts instance_arn = local.instance_arn permission_set_arn = aws_ssoadmin_permission_set.admin.arn principal_type = "GROUP" principal_id = aws_identitystore_group.admins.group_id target_type = "AWS_AC...
rshutt/rshutt-exercise
BSD-3-Clause
infra/aws/bootstrap/05-identity-center/account-assignments.tf
aws
[ "aws_ssoadmin_account_assignment" ]
6032dc07493b64c208e34c468809cfc2
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM role named GlueRole that AWS Glue can assume, attach the AWSGlueServiceRole, AmazonS3FullAccess, AWSGlueConsoleFullAccess, AmazonRDSFullAccess, and SecretsManagerReadWrite managed policies to it, and also attach a custom policy named custom-jdbc-glue-policy that allows the role to pass any IAM role to AWS...
resource "aws_iam_role" "glue" { name = "GlueRole" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Principal = { Service = "glue.amazonaws.com" } Action = "sts:AssumeRole" } ] }) } # https://docs.aws.amazo...
epomatti/aws-glue-athena
MIT
modules/iam/glue/main.tf
aws
[ "aws_iam_policy", "aws_iam_role", "aws_iam_role_policy_attachment" ]
ab633d710abb63c3354b1b6f3a586945
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create a Route 53 hosted zone named after the domain variable only when enabled, associate it with two specific VPCs (the primary VPC and an additional associated VPC) in the same region, set the hosted zone comment to “Managed by Terraform”, and ensure it cannot be destroyed if it still contains records.
resource "aws_route53_zone" "hosted_zone" { name = var.enabled_hosted_zone ? var.domain : 0 comment = "Managed by Terraform" force_destroy = false vpc { vpc_id = var.vpc_id vpc_region = var.region } vpc { vpc_id = var.associated_vpc_id vpc_region = var.region } }
technotriosllc/aws-cloud
Apache-2.0
base-infra/modules/hosted_zone_config/main.tf
aws
[ "aws_route53_zone" ]
26e23cdfe0f719e362333ba46430e54d
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create route table associations that link each private subnet (one for every CIDR in `var.private_subnet_cidrs`) to the private route table, and each public subnet (one for every CIDR in `var.public_subnet_cidrs`) to the public route table.
resource "aws_route_table_association" "private" { count = length(var.private_subnet_cidrs) subnet_id = aws_subnet.private[count.index].id route_table_id = aws_route_table.private.id } resource "aws_route_table_association" "public" { count = length(var.public_subnet_cidrs) subnet_id ...
gordonmurray/terraform-project.com
MIT
terraform/route_table_associations.tf
aws
[ "aws_route_table_association" ]
0df0ca4f7c37263eb5a7c5962d949e30
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an ECS task definition with a configurable family name, container definitions, CPU, memory, and network mode, supporting optional runtime platform settings, ephemeral storage, proxy configuration, placement constraints, and multiple volume types including Docker, EFS, and FSx for Windows File Server volumes with...
resource "aws_ecs_task_definition" "this" { family = var.family container_definitions = var.container_definitions region = var.region cpu = var.cpu memory = var.memory network_mode = var.network_mode ipc_mode ...
davidshare/terraform-aws-modules
MIT
ecs_task_definition/main.tf
aws
[ "aws_ecs_task_definition" ]
aef3cbeb11fc853e682859b8d80b5ab9
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 a variable, using on-demand or provisioned billing as configured, with a primary key on the `id` string attribute and a global secondary index named `userId-index` partitioned by a `userId` string attribute that projects all attributes, and enable point-in-time recovery if specified.
# modules/data/main.tf # DynamoDB table resource "aws_dynamodb_table" "this" { name = var.table_name billing_mode = var.billing_mode hash_key = "id" attribute { name = "id" type = "S" } # GSI for user-based queries attribute { name = "userId" type = "S" } global_seconda...
berTrindade/terraform-infrastructure-blueprints
MIT
blueprints/aws/apigw-lambda-dynamodb-cognito/modules/data/main.tf
aws
[ "aws_dynamodb_table" ]
b1fcadc0bf2823e403fc82623593df34
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an IAM group named “developers_group” with a specified path, attach a custom policy granting read-only access to IAM and full access to S3, create a set of IAM users defined in a variable, attach a separate custom policy allowing EC2 console screenshot access to each user, add each user to the developers group, ...
locals { create_iam_group = var.create_iam_group create_iam_read_only_and_s3_full_access_policy = var.create_iam_read_only_and_s3_full_access_policy create_iam_read_only_and_s3_full_access_policy_attachment = var.create_iam_read_only_and_s3_full_access_policy_at...
mohammadll/aws-terraform
MIT
modules/IAM/main.tf
aws
[ "aws_iam_group", "aws_iam_group_policy_attachment", "aws_iam_policy", "aws_iam_role", "aws_iam_user", "aws_iam_user_group_membership", "aws_iam_user_policy_attachment" ]
b51cc5706cd862ea0922be13ce2674e6
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Create an Amazon EMR cluster named according to `var.cluster_name` using the specified release label and applications, configured with either instance groups (if deploying multi-master with only on-demand instances) or instance fleets (if using spot instances or single-master), specifying master and core instance types...
locals { applications = [for app in var.applications : lower(app)] # Instance groups are required if deploying multi-master but instance fleets are required # if using both on-demand and spot instances. # Use instance group only if multi-master and no spot instances. # Otherwise deploy as fleet which will re...
Datatamer/terraform-aws-emr
Apache-2.0
modules/aws-emr-cluster/main.tf
aws
[ "aws_emr_cluster" ]
26d3e9ac986d50c5e045094ab61d7131
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences.
Launch an EC2 instance using the latest Ubuntu 22.04 LTS AMI from Canonical, with the instance type specified by a variable, a key pair named by a variable, deployed into a subnet specified by a variable, and secured with a primary security group plus any additional security groups provided via variables, while tagging...
data "aws_ami" "ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-*-22.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical } resource "aws_instance" "this" { ami ...
4kleiber/tfm-jumphost
Apache-2.0
ec2-instance.tf
aws
[ "aws_instance" ]
159f0e2716ba7098417a84e600fb535e