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. | Provision an Ubuntu virtual machine with the latest AMI matching specific filters, assign it a public IP in the first availability zone, and join it to the web security group; generate a 16-character WordPress admin password including special characters _ % @; configure the instance via cloud-init to connect to the dat... | # provision the admin Ubuntu virtual machine
data "aws_ami" "ubuntu_admin" {
most_recent = var.ami_most_recent
owners = [var.ami_owners]
filter {
name = "name"
values = [var.ami_filter_name]
}
filter {
name = "virtualization-type"
values = [var.ami_filter_virtualization_type]
}
}
# creat... | TaskMasterErnest/Infrastructure-As-Code-With-WordPress-And-Terraform | MIT | terraform/05-vm_admin.tf | aws | [
"aws_instance",
"aws_lb_target_group_attachment",
"random_password"
] | 3c5373ed4d488806a55d94b26666fb97 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudFront distribution for a frontend S3 bucket, configured with an origin access identity to restrict direct S3 access, enabled with IPv6 support, serving index.html as the default root object, allowing all HTTP methods but caching only GET and HEAD requests, using the CloudFront default SSL certificate, log... | resource "aws_cloudfront_distribution" "cloudfront_dist" {
origin {
domain_name = var.cloudfront_origin_s3_bucket
origin_id = var.cloudfront_origin_s3_bucket
s3_origin_config {
origin_access_identity = aws_cloudfront_origin_access_identity.cloudfront_dist_oai.cloudfront_access_identity_pa... | haarshdev/terraform-with-AWS | MIT | terraform/modules/app/cloudfront/main.tf | aws | [
"aws_cloudfront_distribution",
"aws_cloudfront_origin_access_identity"
] | 05411e691fe8d38bb1871d592606fba9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create four customer-managed KMS keys named using the network name prefix—one each for encrypting EC2 resources, RDS databases, S3 buckets, and Secrets Manager secrets—each with a 7-day deletion window, automatic key rotation enabled every 90 days, and a policy granting full permissions to the account root, service pri... | # KMS keys for resource encryption
data "aws_caller_identity" "current" {}
resource "aws_kms_key" "ec2_key" {
description = "KMS key for EC2 encryption"
deletion_window_in_days = 7
rotation_period_in_days = 90
enable_key_rotation = true
policy = jsonencode({
Version = "2012-10-17"
St... | desaidhruvOrg/tf-aws-infra | MIT | kms.tf | aws | [
"aws_kms_alias",
"aws_kms_key"
] | 602000b1b288ab410142c2dbe274131e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EKS node group named “unpaid-developers-singapore-nodes” in the unpaid_developers_singapore_eks_cluster, using two private subnets, Spot capacity with t3.2xlarge instances, 100 GB root storage, and scaling between 1 and 7 nodes (desired 4), labeled as “general” for standard workloads; and a second GPU-enabled... | # General purpose node group for standard workloads
resource "aws_eks_node_group" "unpaid_developers_singapore_nodes" {
cluster_name = aws_eks_cluster.unpaid_developers_singapore_eks_cluster.name
node_group_name = "unpaid-developers-singapore-nodes"
node_role_arn = aws_iam_role.unpaid_developers_eks_nodes_ro... | The-Unpaid-Developers/manifest | MIT | terraform/modules/eks/nodes.tf | aws | [
"aws_eks_node_group"
] | 26b5a94feedcae38dd4bdd089b2a0d15 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a single Elastic IP address associated with the main EC2 instance, ensure it is not automatically destroyed when removed from the configuration, and tag it with the tenant, project, EC2 name, environment, maintainer “Magicorn”, and Terraform “yes” metadata. | ##### Create EC2 IPs
resource "aws_eip" "main" {
count = (var.create_eip == true) ? 1 : 0
instance = aws_instance.main.id
domain = "vpc"
lifecycle {
prevent_destroy = true
}
tags = {
Name = "${var.tenant}-${var.name}-${var.ec2_name}-eip-${var.environment}"
Tenant = var.... | magicorntech/terraform-aws-ec2-instance | MIT | eip.tf | aws | [
"aws_eip"
] | 1d1e74c9ed9bceff8eb35f74e77f12a9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create four security groups in the specified VPC: one named “alb_sg” allowing inbound HTTP on port 80 from anywhere and all outbound traffic; one named “bastion_sg” allowing inbound SSH on port 22 from anywhere (for development only) and all outbound traffic; one named “app_sg” allowing inbound traffic on port 5000 onl... | # modules/security/main.tf
variable "vpc_id" {}
resource "aws_security_group" "alb_sg" {
name = "alb_sg"
description = "Allow inbound HTTP from anywhere"
vpc_id = var.vpc_id
ingress {
description = "HTTP from anywhere"
from_port = 80
to_port = 80
protocol = "tcp"
cidr... | Hassa678/Log_visito_app | MIT | modules/security/main.tf | aws | [
"aws_security_group"
] | 7eac920ad1257cdd86a28c59a561fc2a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Generate an ED25519 private key, export its OpenSSH public and private key formats to local files with permissions 0644 and 0600 respectively, and register the public key in AWS under the name “london-tube-lines” as a key pair. | resource "tls_private_key" "london_tube_lines_tls_private_key" {
algorithm = "ED25519"
}
resource "local_file" "london_tube_lines_public_openssh_key" {
filename = var.ssh_public_key_filename
content = tls_private_key.london_tube_lines_tls_private_key.public_key_openssh
file_permission = "0644"
}... | ssbostan/london-tube-lines | Apache-2.0 | infra/modules/keypair/main.tf | aws | [
"aws_key_pair",
"local_file",
"tls_private_key"
] | 7c76e559373c2a368903ff8b3eba5b21 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `cron-scheduler-role` that AWS EventBridge Scheduler can assume, attach a policy named `cron-scheduler-policy` to it, and grant that policy permission to invoke a specific Lambda function named `appstreamdiskincreaser`. | resource "aws_iam_role" "scheduler" {
name = "cron-scheduler-role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = ["scheduler.amazonaws.com"]
}
Action = "sts:AssumeRole"
}
]
})
}
r... | sogeti-demo/AWS-Appstream-disk-management | MIT | iam-eventbridge.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | b97f50edc3c1e045f06a80be2240f0de |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named by the `distribution_bucket_name` variable to host GitHub Actions runner distributions, enforce bucket-owner-controlled object ownership, enable versioning based on the `s3_versioning` variable, configure lifecycle rules to abort incomplete multipart uploads after 7 days and transition objects... | locals {
action_runner_distribution_object_key = "actions-runner-${var.runner_os}.${var.runner_os == "linux" ? "tar.gz" : "zip"}"
}
resource "aws_s3_bucket" "action_dist" {
bucket = var.distribution_bucket_name
force_destroy = true
tags = var.tags
}
resource "aws_s3_bucket_ownership_controls" ... | philips-labs/terraform-aws-github-runner | MIT | modules/runner-binaries-syncer/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_logging",
"aws_s3_bucket_ownership_controls",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning"
] | a1ceda527405602eade0b2e0c84510d0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM user named with the environment prefix followed by “-baseline”, generate an access key for it, attach a policy allowing it to assume the OrganizationAccountAccessRole in the target account, and store the access key’s ID, secret, and encrypted secret in AWS Secrets Manager under a secret named with the env... | data "aws_iam_policy_document" "baseline_iam_policy_document" {
version = "2012-10-17"
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
resources = ["arn:aws:iam::${var.target_account_id}:role/OrganizationAccountAccessRole"]
}
}
resource "aws_iam_user" "baseline" {
name = "${var.env}... | Pivopil/awsdevbot-root-baseline | MIT | modules/iam-credentials/main.tf | aws | [
"aws_iam_access_key",
"aws_iam_user",
"aws_iam_user_policy",
"aws_secretsmanager_secret",
"aws_secretsmanager_secret_version"
] | fd77abb886a5177a4941fcf392280c4f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a DynamoDB table named “project1-serverless-[table_name]-[environment]” with on-demand billing, using a partition key whose name and type are provided via variables. | // modules/dynamodb/main.tf
resource "aws_dynamodb_table" "this" {
name = "project1-serverless-${var.table_name}-${var.environment}"
billing_mode = "PAY_PER_REQUEST"
hash_key = var.partition_key_name
attribute {
name = var.partition_key_name
type = var.partition_key_type
}
} | anandmathew9605/project1-serverless | MIT | infra/modules/dynamodb/main.tf | aws | [
"aws_dynamodb_table"
] | aed211882b2205f979850a36501089a1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Enable server-side encryption on the specified S3 bucket using the provided encryption rules, ensuring the bucket is owned by the expected account, and configure each rule to enable bucket key usage and apply the specified SSE algorithm (and optional KMS key) by default for all new objects. | resource "aws_s3_bucket_server_side_encryption_configuration" "this" {
region = var.region
bucket = var.bucket
expected_bucket_owner = var.expected_bucket_owner
dynamic "rule" {
for_each = var.rule
content {
bucket_key_enabled = rule.value.bucket_key_enabled
d... | ebogdum/terraform-providers | MIT | aws/resources/s3_bucket_server_side_encryption_configuration/main.tf | aws | [
"aws_s3_bucket_server_side_encryption_configuration"
] | f864c355621e87783f8c23619bb4ed46 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Upload a specific HTML file to an S3 bucket using a given key, make the object publicly readable, and ensure its content type is explicitly set to text/html. | resource "aws_s3_object" "site" {
bucket = var.s3_object_bucket
key = var.s3_object_key
source = var.s3_object_file
content_type = "text/html"
acl = "public-read"
} | tapplay-tech/terraform-mod-frontend | MIT | frontend/s3_object/main.tf | aws | [
"aws_s3_object"
] | ef8aac4841bdbefc196d865e00210309 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Access Analyzer analyzer named using the provided name variable or derived from the environment and name variables, with the analyzer type set to the uppercase value of the analyzer type variable, and enable it conditionally based on the enable_accessanalyzer_analyzer variable. | #---------------------------------------------------
# AWS accessanalyzer analyzer
#---------------------------------------------------
resource "aws_accessanalyzer_analyzer" "accessanalyzer_analyzer" {
count = var.enable_accessanalyzer_analyzer ? 1 : 0
analyzer_name = var.accessanalyzer_analyzer_name != "" ? var.... | SebastianUA/terraform | Apache-2.0 | aws/modules/access_analyzer/accessanalyzer_analyzer.tf | aws | [
"aws_accessanalyzer_analyzer"
] | 64b17f981d9c138cef0b3909ab2cb72d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CI/CD user named `cicd-os` with tags for identification and a description indicating it serves multiple repositories, grant it permission to assume a specific IAM role for Aurora Serverless Laravel and pass roles to CloudFormation, and attach a policy allowing it to deploy to CloudFormation stacks and S3 bucke... | resource "aws_iam_user" "cicd-os" {
name = var.cicd-name
tags = {
Name = var.cicd-name,
Description = "Common CI/CD user for many repositories."
}
}
resource "aws_iam_user_policy" "cicd-allow-assume-role" {
user = aws_iam_user.cicd-os.name
policy = data.aws_iam_policy_document.cicd-allow-ass... | rdok/cicd-iam-terraform | MIT | user.tf | aws | [
"aws_iam_policy",
"aws_iam_user",
"aws_iam_user_policy",
"aws_iam_user_policy_attachment"
] | a9f72b0fe4e21ea9c911c6c7c1763740 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Configure the specified S3 bucket as a static website with a customizable index document suffix, an optional error document key, and an optional redirect rule for all requests to a single host and protocol; also apply the provided routing rules. | resource "aws_s3_bucket_website_configuration" "website-config" {
bucket = var.bucket_id
dynamic "index_document" {
for_each = var.index_document != null ? { my = var.index_document } : {}
content {
suffix = try(index_document.value.suffix, null)
}
}
dynamic "error_document" {
for_each =... | hoverkraft-tech/terraform-modules | MIT | aws/s3-bucket-website-configuration/website-config.tf | aws | [
"aws_s3_bucket_website_configuration"
] | 494473a134f3c6786e8504143f54a82e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a DMS replication instance named “postgres-dms-replication-instance-tf” using a t2.micro instance class, allocate 20 GB of storage, make it publicly accessible, disable multi-AZ, and place it in the availability zone specified by the `repli_instance_az` variable, with the security group ID provided via the `repl... | # Create a new replication instance
resource "aws_dms_replication_instance" "migration-postgres" {
allocated_storage = 20
apply_immediately = true
auto_minor_version_upgrade = true
availability_zone = var.repli_instance_az
#engine_version = "3.1.4"
#kms_key_a... | cihejimba/aws | MIT | terraform/dms/replication_instance.tf | aws | [
"aws_dms_replication_instance"
] | 8359e5ebd8cc6654b255f58f9e730f09 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM group named “infra-team” and attach the AWS managed policies IAMReadOnlyAccess and AmazonRoute53ReadOnlyAccess to it, along with two custom policies: one allowing members to manage their own credentials and another enforcing MFA for all group members. | // Permissions for the members of the infra team as a whole.
resource "aws_iam_group" "infra_team" {
name = "infra-team"
}
resource "aws_iam_group_policy_attachment" "infra_team_manage_own_credentials" {
group = aws_iam_group.infra_team.name
policy_arn = aws_iam_policy.manage_own_credentials.arn
}
resourc... | rust-lang/simpleinfra | MIT | terraform/team-members-access/infra-team.tf | aws | [
"aws_iam_group",
"aws_iam_group_policy_attachment"
] | bad69e0fa3222dc11f05d0ce1b350621 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a directory service log subscription in the specified region that forwards logs from the given directory to the designated CloudWatch log group. | resource "aws_directory_service_log_subscription" "this" {
region = var.region
directory_id = var.directory_id
log_group_name = var.log_group_name
} | ebogdum/terraform-providers | MIT | aws/resources/directory_service_log_subscription/main.tf | aws | [
"aws_directory_service_log_subscription"
] | 2e5f7885f2406a3fd981f415aecd399b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an internet-facing Application Load Balancer named via variable, configured with IPv4 addressing, deletion protection, HTTP/2, cross-zone load balancing, and dropped invalid header fields; enable access logging to a newly created S3 bucket (or an existing one if specified), with the bucket locked down to block a... | resource "aws_lb" "application_load_balancer" {
name = var.alb_name
load_balancer_type = "application"
internal = false
subnets = var.public_subnet_ids
security_groups = [var.alb_security_group_id]
enable_deletion_protection = var.enab... | trade-tariff/trade-tariff-platform-aws-terraform | MIT | modules/application-load-balancer/main.tf | aws | [
"aws_lb",
"aws_lb_listener",
"aws_lb_listener_rule",
"aws_lb_target_group",
"aws_s3_bucket",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block"
] | 353fb9dff53b2ec1163d520592bb254d |
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 prefix “data-warehouse-” that automatically deletes all contents on destroy and enforces bucket-owner ownership while blocking all public access. Set up two Lambda functions named “poke-scheduler” and “poke-scraper” using the provided ZIP file, running on ARM64 with a 2-minute timeout... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
variable "zip_path" {
type = string
default = ""
}
variable "region" {
type = string
}
provider "aws" {
region = var.region
}
data "aws_iam_policy_document" "lambda_assume_policy" {
statement {
actions = ["s... | BielosX/wombat | MIT | poke-scraper/infra/main.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_lambda_function",
"aws_s3_bucket",
"aws_s3_bucket_ownership_controls",
"aws_s3_bucket_public_access_block",
"aws_sfn_state_machine"
] | 1833d7e7659e26a385709eb1c31d314b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a route table named `route_pawelkur` in the VPC `main_pawelkur` that routes all traffic (0.0.0.0/0) to the internet gateway `igw_pk`. | resource "aws_route_table" "route_pawelkur" {
vpc_id = "${aws_vpc.main_pawelkur.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw_pk.id
}
} | PawelK14/slackbot | MIT | infrastructure/networking/modules/vpc_module/routetable.tf | aws | [
"aws_route_table"
] | 319db8d559a9d17d50d8f2ce4b8a5c93 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS Fargate service named with the environment prefix that runs a single container using the specified CPU and memory, pulls its image from the given repository URL with the specified tag, exposes the application port, and is only accessible via the ALB’s security group while allowing all outbound traffic; de... | # Traffic to the ECS Cluster should only come from the ALB
resource "aws_security_group" "ecs_tasks_security_group" {
name = "${var.environment}-ecs-task"
description = "allow inbound access from the ALB only"
vpc_id = var.main_vpc_id
ingress {
protocol = "tcp"
from_port = var.... | bridgecrew-perf6/fargate-deployment-pipeline | MIT | infra/deployment/modules/application/fargate.tf | aws | [
"aws_ecs_service",
"aws_ecs_task_definition",
"aws_security_group"
] | 4908f70fc10d21d79bf7135e84196f63 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with DNS hostnames and support enabled, using a configurable CIDR block, and tag it with the project name suffixed by "-vpc". Provision an internet gateway attached to the VPC and a NAT gateway in the first public subnet, backed by a dedicated Elastic IP, to enable outbound internet access for private subn... | resource "aws_vpc" "main" {
instance_tenancy = "default"
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
enable_dns_support = true
tags = merge(var.common_tags, {
Name = "${var.project_name}-vpc"
})
}
resource "aws_internet_gateway" "main" {
vpc_id = aws_vpc.main.id
tags = m... | cmorellh/aws-infra-tiers | MIT | tier-1-ec2/modules/vpc/main.tf | aws | [
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 0959ad984dc907674235dce4158a360f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a KMS key with a 10-day deletion window for encrypting backup vault data, and associate it with a user-friendly alias derived from the variable `backup_vault_key_name`. | resource "aws_kms_key" "backup_vault" {
description = var.backup_vault_key_desc
deletion_window_in_days = 10
}
resource "aws_kms_alias" "backup_vault" {
name = "alias/${var.backup_vault_key_name}"
target_key_id = aws_kms_key.backup_vault.key_id
} | jeffnelson1/terraform-configs-aws | Apache-2.0 | aws-backup/kms_keys.tf | aws | [
"aws_kms_alias",
"aws_kms_key"
] | 504ca6fd7dc505ba70ca726eb949dcb0 |
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 `resume.example.com` (where `example.com` is provided via the `domain-name` variable), including a wildcard subject alternative name for `*.example.com`, using the validation method specified in the `validation-method` variable, and ensure the certificate is created before any ... | # --- root/aws/tf/modules/acm-certificate/main.tf ---
resource "aws_acm_certificate" "this" {
domain_name = "resume.${var.acm_certificate["domain-name"]}"
validation_method = var.acm_certificate["validation-method"]
subject_alternative_names = ["*.${var.acm_certificate["domain-name"]}"]
lifecycle {
... | subhamay-bhattacharyya/cloud-resume-challenge | MIT | infra/aws/tf/modules/acm/main.tf | aws | [
"aws_acm_certificate"
] | 9a9f479c0f291440b4df8347fab90109 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an autoscaling policy named “web_policy_up” that adds one instance to the “web” autoscaling group after a 300-second cooldown, and another named “web_policy_down” that removes one instance under the same cooldown. Set up a CloudWatch alarm named “web_cpu_alarm_up” that triggers when average CPU utilization is at... | resource "aws_autoscaling_policy" "web_policy_up" {
name = "web_policy_up"
scaling_adjustment = 1
adjustment_type = "ChangeInCapacity"
cooldown = 300
autoscaling_group_name = aws_autoscaling_group.web.name
}
resource "aws_cloudwatch_metric_alarm" "web_cpu_alarm_up" {... | kyalders/tstapp-aws | MIT | asg_policy.tf | aws | [
"aws_autoscaling_policy",
"aws_cloudwatch_metric_alarm"
] | a9664f86559f8ce943e9a8dc66cae9d1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named via `var.iam_role_name` that allows the Lambda service to assume it, package a Lambda function from a source file into a ZIP archive, and deploy that function with a name, handler, runtime, and timeout specified via variables—attach the AWS-managed VPC access policy to the role, configure the f... | resource "aws_iam_role" "lambda_exec_role" {
name = var.iam_role_name
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Effect = "Allow",
Principal = { Service = "lambda.amazonaws.com" },
Action = "sts:AssumeRole"
}]
})
}
data "archive_file" "lambda" {
... | GrabAByte/terraform-module-aws-lambda | MIT | main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment",
"aws_lambda_function",
"aws_lambda_permission"
] | 9bca538303d3877482e8bfc043bae279 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision three Red Hat Enterprise Linux instances, each with t2.micro size, named Demo1_server, Demo2_server, and Demo3_server, all using the same security group and placed in three distinct public subnets across different availability zones. | resource "aws_instance" "demo1" {
count = 1
ami = var.redhatami
instance_type = "t2.micro"
security_groups = [aws_security_group.ec2-security-group.id]
subnet_id = aws_subnet.public-subnet-1.id
#security_groups = [aws_security_group.ec... | richmanproject/Cassandra | MIT | terraform/ec2_instances.tf | aws | [
"aws_instance"
] | 0cbebc5cd383ac99d65ef1fc56c6512d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group named “Moodle EC2 Security Group” in the `tstapp-vpc` VPC that allows inbound HTTP (port 80), HTTPS (port 443), and SSH (port 22) traffic from any IP address, and permits all outbound traffic to any destination. | # Creating Security Group for ALB
resource "aws_security_group" "tstapp-ec2-sg" {
name = "Moodle EC2 Security Group"
description = "Moodle EC2 SG Module"
vpc_id = aws_vpc.tstapp-vpc.id
# Inbound Rules
# HTTP access from anywhere
ingress {
from_port = 80
to_port = 80
protocol ... | kyalders/tstapp-aws | MIT | sg_ec2.tf | aws | [
"aws_security_group"
] | 5a800b65db1eca217f0b8143f601444a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a KMS key with a configurable alias, description, deletion window, and key rotation, and an S3 bucket named exactly as specified with versioning enabled, static website hosting configured with a specific index and error document, server-side encryption using the KMS key, and strict public access blocking; also c... | #
# kms key
#
resource "aws_kms_key" "kms-key" {
count = var.aws_kms_key.enabled ? 1 : 0
description = var.aws_kms_key.description
policy = data.aws_iam_policy_document.kms-policy.json
deletion_window_in_days = var.aws_kms_key.deletion_window_in_days
enable_key_rotation = va... | salizzar/terraform-modules | MIT | aws/s3-bucket/main.tf | aws | [
"aws_dynamodb_table",
"aws_kms_alias",
"aws_kms_key",
"aws_s3_bucket",
"aws_s3_bucket_acl",
"aws_s3_bucket_logging",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning",
"aws_s3_bucket_website_configuration... | 3a8cb2952d80d2516a1da2508996312e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS task definition using the name from the variable, assign it the ARNs of the pre-created IAM roles for task execution and task operations, embed the container definitions provided as a JSON string, configure the task to use the specified network mode, CPU, and memory values, set its compatibility modes as ... | resource "aws_ecs_task_definition" "main" {
family = var.name
task_role_arn = aws_iam_role.ecs_task_role.arn
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
container_definitions = var.container_definition_json
network_mode = var.network_mode
cpu ... | ohpensource/terraform-aws-ohp-ecs | Apache-2.0 | modules/task/main.tf | aws | [
"aws_ecs_task_definition"
] | 1f355c749b8e4f3df810922f9bccf0b3 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an HTTP API Gateway with a name derived from project, environment, and name variables, including CORS settings configured via variables for allowed origins, methods, headers, and max age; deploy it automatically to a default stage; optionally configure a custom domain name with a regional endpoint using TLS 1.2 ... | resource "aws_apigatewayv2_api" "main" {
name = "${var.project}-${var.environment}-${var.name}"
protocol_type = "HTTP"
version = var.api_version
cors_configuration {
allow_origins = var.cors_allow_origins
allow_methods = var.cors_allow_methods
allow_headers = var.cors_allow_headers
... | opstimus/terraform-aws-api-gateway | Apache-2.0 | main.tf | aws | [
"aws_apigatewayv2_api",
"aws_apigatewayv2_api_mapping",
"aws_apigatewayv2_deployment",
"aws_apigatewayv2_domain_name",
"aws_apigatewayv2_stage"
] | adc47de4d5d61d6d17f7b451a6d6cd76 |
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 `<client>-<env>-<project>-lambda-role` that AWS Lambda can assume, attach a policy named `<client>-<env>-<project>-lambda-policy` containing the provided permissions, deploy a Lambda function named `<client>-<env>-<project>-lambda-function` using the specified code, handler, ru... | terraform {
}
resource "aws_iam_role" "this" {
name = format("%s-%s-%s-lambda-role", var.client, var.env, var.project)
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"E... | blevkovych/groot-telegram-bot | MIT | modules/terraform-aws-lambda/main.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_lambda_function",
"aws_lambda_permission"
] | 40a2b5168c9518fa838d31e11424e487 |
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 a name derived from the `project_name` variable, grant the AWS Lambda service permission to assume it, attach a policy that allows the role to write logs to any CloudWatch log group and to read, write, and list objects in two specific S3 buckets named `raw` and `curated`. | data "aws_iam_policy_document" "lambda_assume" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
resource "aws_iam_role" "lambda_role" {
name = "${var.project_name}-lambda-role"
assume_role_policy =... | johnmiller-lovescode/boston-transit-data-pipeline | MIT | terraform/iam.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 0d39a0bda8fc845e603af06246ff3454 |
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 resource variable, attached to the default VPC, that permits inbound HTTP traffic on port 80 from any IPv4 address and allows all outbound traffic to any IPv4 address. | # Security group
resource "aws_security_group" "default_sg" {
name = "${var.resource_name}_security_group"
description = "Allow HTTP port 80"
vpc_id = data.aws_vpc.vpc_default.id
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egres... | sajohnstone/bootstrap-ec2 | Apache-2.0 | security-group.tf | aws | [
"aws_security_group"
] | fa2483b2e0f8b36abd10757407e7c322 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket named `delius-psn-terraform-state` in the `eu-west-2` region with versioning enabled, private access control, and protection against accidental deletion; set up a DynamoDB table named `delius-psn-terraform-state-lock` with 20 read and 20 write capacity units, using `LockID` as the primary key, and e... | provider "aws" {
region = "${var.aws_region}"
}
terraform {
backend "s3" {
encrypt = true
bucket = "delius-psn-terraform-state"
region = "eu-west-2"
dynamodb_table = "delius-psn-terraform-state-lock"
key = "terraform/terraform.tfstate"
}
}
resource "aws_s3_b... | ministryofjustice/hmpps-delius-psn-terraform | MIT | main.tf | aws | [
"aws_dynamodb_table",
"aws_s3_bucket"
] | f7cf90514db1d9b93b19e585e8157c34 |
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, two public and two private subnets across two availability zones, an internet gateway, one NAT gateway, and route tables routing public traffic to the internet and private traffic through the NAT gateway. Set up an S3 bucket with versioning and AES256 encryption, plus a sample text f... | # =============================================================================
# DATA SOURCES
# =============================================================================
data "aws_region" "current" {}
data "aws_caller_identity" "current" {}
# Random string for S3 bucket name uniqueness
resource "random_id" "buck... | jdevto/tf-aws-s3-efs-datasync-demo | MIT | main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_datasync_location_efs",
"aws_datasync_location_s3",
"aws_datasync_task",
"aws_efs_file_system",
"aws_efs_mount_target",
"aws_eip",
"aws_iam_instance_profile",
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment",
"aws_instance",
"aws_intern... | 87baad08043a0d006402f26d10ec7ad6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudFront response headers policy named according to the `var.name` variable, with an optional comment, that configures CORS rules including allowed origins, headers, methods, credentials, exposed headers, and max age, plus optional custom headers to add or override, headers to remove, and security headers fo... | resource "aws_cloudfront_response_headers_policy" "this" {
count = var.enabled ? 1 : 0
name = var.name
comment = var.comment
dynamic "cors_config" {
for_each = var.cors_config
content {
access_control_allow_credentials = cors_config.value.access_control_allow_credentials
dynamic "acce... | finisterra-io/terraform-aws-cloudfront | Apache-2.0 | modules/response_headers_policy/main.tf | aws | [
"aws_cloudfront_response_headers_policy"
] | fd661f916e9614cebca0e48b6da343cb |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with a configurable prefix, enable versioning, block all public access by preventing public ACLs, policies, and cross-account access, and set up a lifecycle policy that marks current objects for deletion after a specified number of days and removes noncurrent versions after another specified number ... | #create s3 bucket
resource "aws_s3_bucket" "this" {
bucket_prefix = var.bucket_prefix
# tags = merge(tomap({ "Name" = "${aws_s3_bucket.this.id}" }), var.tags)
force_destroy = var.force_destroy_bucket
}
# Enabled bucket versioning
resource "aws_s3_bucket_versioning" "versioning" {
bucket = aws_s3_bucket.this.... | CDCgov/NEDSS-Infrastructure | Apache-2.0 | terraform/aws/app-infrastructure/s3-bucket/main.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_lifecycle_configuration",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_versioning"
] | cb1e9a46ae8e2026ca5f4d0f9c971e5e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS DataZone domain with a name, description, and version specified via variables, assign the domain execution role and service role, configure a KMS key for encryption, optionally enable single sign-on with a specified type and user assignment setting, set custom create and delete timeouts, and apply tags. | resource "aws_datazone_domain" "this" {
name = var.name
domain_execution_role = var.domain_execution_role
region = var.region
description = var.description
domain_version = var.domain_version
kms_key_identifier = var.kms_key_identifier
service_role = var... | ebogdum/terraform-providers | MIT | aws/resources/datazone_domain/main.tf | aws | [
"aws_datazone_domain"
] | 5dc4b95e5386e7d29413a8342b6e7107 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with an optional IPv6-native configuration, including public and private subnets distributed across availability zones, an internet gateway for IPv4 egress, an egress-only internet gateway for IPv6-only traffic, a NAT gateway in a public subnet for private subnet IPv4 internet access, and associated route ... | # VPC
resource "aws_vpc" "vpc" {
cidr_block = try(var.vpc_settings.vpc_cidr_block, "")
assign_generated_ipv6_cidr_block = var.vpc_settings.enable_aws_ipv6_cidr_block.ipv6_native == true || var.vpc_settings.enable_aws_ipv6_cidr_block.public_cidr_count_prefix64 != 0 || var.vpc_settings.enable_aws_ipv6_cidr_... | obreo/effortless-eks | MIT | modules/vpc/vpc.tf | aws | [
"aws_egress_only_internet_gateway",
"aws_eip",
"aws_internet_gateway",
"aws_nat_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc",
"aws_vpc_endpoint",
"aws_vpc_security_group_egress_rule",
"aws_vpc_security_group_ingress_rule"
] | 111f9428681fe6b1bce5fdca99242ddc |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create HTTPS subscriptions for an SNS topic for each entry in the subscriptions variable, using the specified topic ARN and endpoint URL, automatically confirm the endpoint, and apply a JSON filter policy only if a non-empty filter string is provided. | resource "aws_sns_topic_subscription" "sns-to-http" {
for_each = var.subscriptions
topic_arn = each.value.topic
protocol = "https"
endpoint = each.value.url
endpoint_auto_confirms = true
filter_policy = ("" != each.value.filter) ? each.value.fi... | genstackio/terraform-aws-sns | MIT | modules/https-subscriptions/main.tf | aws | [
"aws_sns_topic_subscription"
] | 2ba01f8d5ed0d0c942b142b9497015d3 |
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 (or Lambda@Edge) with optional CloudWatch Logs, dead letter queue, VPC, X-Ray tracing, and async event destination permissions; if Lambda@Edge is enabled, use a wildcard region in the CloudWatch Log Group ARN for logging across regions; support attaching up to two additional JSO... | locals {
create_role = var.create && var.create_function && !var.create_layer && var.create_role
# Lambda@Edge uses the Cloudwatch region closest to the location where the function is executed
# The region part of the LogGroup ARN is then replaced with a wildcard (*) so Lambda@Edge is able to log in every region... | fabiopalumbo/test-retargely | Apache-2.0 | modules/lambda/iam.tf | aws | [
"aws_iam_policy",
"aws_iam_role",
"aws_iam_role_policy_attachment"
] | 8571d89f609b99989098ef81a53cf868 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC with a CIDR block specified by the `cidr_vpc` variable, enable DNS hostnames, and tag it with the name “GrayMetaPlatform-<platform_instance_id>”, application “GrayMetaPlatform”, and platform instance ID matching the `platform_instance_id` variable. | resource "aws_vpc" "main" {
cidr_block = var.cidr_vpc
enable_dns_hostnames = true
tags = {
Name = "GrayMetaPlatform-${var.platform_instance_id}"
Application = "GrayMetaPlatform"
PlatformInstanceID = var.platform_instance_id
}
} | WasabiAiR/terraform12-aws-platform | Apache-2.0 | modules/network/vpc/vpc.tf | aws | [
"aws_vpc"
] | 1034c346c30d6755b96b348fd8831dbc |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a single t2.micro EC2 instance in us-east-2 using the latest Ubuntu 14.04 LTS AMI from Canonical, with the key pair named “ec2”, and tag the instance as “HelloWorld”; also output the SSH command to connect to it using the key file “ec2.pem”. | provider "aws" {
region = "us-east-2"
version = "~> 2.69"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["09972010947... | desainis/learn-terraform | MIT | e1/main.tf | aws | [
"aws_instance"
] | 5209d6e1390bdd51fd096602669737f1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group for a jumpbox that allows SSH access (port 22) only from the CIDR blocks specified in the `jumpbox_allowed_ssh` variable, and permit the jumpbox to initiate outbound connections on ports 22, 80, and 443 to any destination on the internet. | resource "aws_security_group_rule" "jumpbox_22_from_cidrs" {
count = length(var.jumpbox_allowed_ssh) > 0 ? 1 : 0
description = "Allow SSH connection from listed CIDRS"
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
security_group_id = aws_security_group.jumpbox_sg.id
cidr_blocks = var.jum... | NHSDigital/integration-adaptors-deployment | Apache-2.0 | aws/components/account/sg_rules_jumpbox.tf | aws | [
"aws_security_group_rule"
] | 20993f17ac077f829906e33db7e2f130 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a DynamoDB table with the name specified by the `table_name` variable, using on-demand billing (PAY_PER_REQUEST), and define a single primary key attribute whose name and type are provided via the `table_main_key` variable. | resource "aws_dynamodb_table" "table" {
name = var.table_name
billing_mode = "PAY_PER_REQUEST"
hash_key = var.table_main_key.name
attribute {
name = var.table_main_key.name
type = var.table_main_key.type
}
} | zLukas/Cloud-infrastructure | MIT | aws/dynamodb/main.tf | aws | [
"aws_dynamodb_table"
] | 157022091cb6a3193980b2d9d8f38c10 |
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 namespace with the suffix “-fabio”, configured with the VPC’s security groups and subnets, and set up two HTTP target groups: one for port 9999 named “-fabio” and another for port 9998 named “-fabio-ui”, both using HTTP health checks on path /health at their respectiv... | resource "aws_alb" "fabio" {
name = "${var.namespace}-fabio"
security_groups = var.vpc_security_group_ids
subnets = var.subnet_ids
}
resource "aws_alb_target_group" "fabio" {
name = "${var.namespace}-fabio"
port = "9999"
vpc_id = data.aws_vpc.demostack.id
protocol = "HTTP"
healt... | GuyBarros/terraform-stacks-hcp-demostack | Apache-2.0 | modules/aws/5_load_balancers/fabio-lb.tf | aws | [
"aws_alb",
"aws_alb_listener",
"aws_alb_target_group",
"aws_alb_target_group_attachment"
] | 06cf5072bf5c360fd92107de6ed964ec |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EC2-based Cloud9 environment named via `var.c9_instance_name` using Amazon Linux 2 x86_64 on a t3.small instance, with IMDSv2 required for metadata access, and attach an IAM instance profile that grants full administrator access to the instance; the environment should be launched in a specific public subnet o... | provider "aws" {
region = var.ct_home_region
}
resource "random_id" "id" {
byte_length = 8
}
resource "aws_iam_role" "cloud9-aft-role" {
name = "cloud9-aft-role-${random_id.id.hex}"
path = "/"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:A... | AlexeiVartoumian/aft9 | MIT-0 | main.tf | aws | [
"aws_cloud9_environment_ec2",
"aws_ec2_instance_metadata_defaults",
"aws_iam_instance_profile",
"aws_iam_role",
"random_id"
] | cc6a154f7411ceed202d663c6e72b44e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EC2 Instance Connect Endpoint in the first private subnet to enable direct SSH access to instances without a bastion host, using a dedicated security group that allows outbound SSH (port 22) only within the VPC’s CIDR block, and only if both the endpoint creation flag and private subnets are enabled. Addition... | #===============================================================================
# EC2 INSTANCE CONNECT ENDPOINT
# Enables secure SSH access to instances in private subnets without bastion hosts
#===============================================================================
resource "aws_ec2_instance_connect_endpoint"... | the-momentum/healthstack | MIT | aws-vpc/module/endpoints.tf | aws | [
"aws_ec2_instance_connect_endpoint",
"aws_security_group",
"aws_vpc_endpoint"
] | b434b77b1261db7b351dde572fe88f3a |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an ECS service named after the `ecs_service_name` variable, running two containers in a single task: the main application container listening on ports 80 and 22, and an Envoy proxy container using the specific App Mesh image from account 840364872350 in eu-west-1, configured with a health check that verifies the... | locals {
main_task = {
name = var.ecs_service_name
image = var.task_specs.image
cpu = var.task_specs.cpu
memory = var.task_specs.memory
essential = true
environment = var.environment_variables
portMappings = [
{
... | renrene/aws-nextcloud | MIT | terraform/app/modules/ecs-service/main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_ecs_service",
"aws_ecs_task_definition"
] | 422e0067951acb2ad451c310313111be |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create three EC2 instances in the us-east-1 region using AMI ami-0b0dcb5067f052a63, with instance types t2.nano, t2.micro, and t2.small respectively, each tagged with a Name value of TF-Server followed by the size key, and expose all public IP addresses as a non-sensitive output. | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
# Configuration options
region = "us-east-1" # North-Virginia
}
resource "aws_instance" "my_server" {
# Using a for_each to define different sizes of the 3 instances
for_each = {
nano = "t2.nano"
... | verma-kunal/DevOps-Cloud-Certifications | MIT | HashiCorp-Terraform-Associate/Code/005-resource-meta-args/for_each/main.tf | aws | [
"aws_instance"
] | 64260fb61dd5107cc591f60458dd31d9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM group named “group-1” in the root path with a policy named “allow-policy” that grants permission to create any IAM resource, but only within the scope of that specific group in account 111111111111. | provider "aws" {
region = "us-east-1"
}
resource "aws_iam_group" "group-1" {
name = "group-1"
path = "/"
}
resource "aws_iam_group_policy" "allow-policy" {
name = "allow-policy"
group = aws_iam_group.group-1.name
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action"... | cysk92/ck-demo | BSD-3-Clause | test/aws/terraform/iam_privilege_escalation_policy_rule/escalation-permissions-self-iam-entity-resource/main.tf | aws | [
"aws_iam_group",
"aws_iam_group_policy"
] | cfb6480406383b1871ed873217f1e155 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a serverless AI service using AWS Lambda that replaces an ECS-based GenAI service, configured to invoke Bedrock models, access an Aurora MySQL database via the RDS Data API, and log to CloudWatch with a 14-day retention; deploy it inside the VPC defined in the network layer, using private application subnets, wi... | # =============================================================================
# Lambda GenAI Layer - GenAI ECS 서비스를 Lambda + Bedrock으로 대체 (단순화됨)
# =============================================================================
# 목적: 서버리스 AI 서비스 제공 (기본 기능만)
# 의존성: 01-network, 02-security 레이어
# 공통 로컬 변수
locals {
# Lam... | hyh528/PetClinic-AWS-Migration | Apache-2.0 | terraform/layers/06-lambda-genai/main.tf | aws | [
"aws_cloudwatch_log_group",
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment",
"aws_lambda_function",
"aws_security_group",
"aws_security_group_rule"
] | 45ae578d583a80a3c6cfba37865f161f |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “preferealty-vpc” with a 10.0.0.0/16 CIDR block, enable both DNS support and DNS hostnames, and set instance tenancy to default. | # Main VPC Configuration
resource "aws_vpc" "preferealty-vpc" {
cidr_block = "10.0.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
instance_tenancy = "default"
tags = {
Name = "preferealty-vpc"
}
} | htranassoc/preferealty-rails | MIT | terraform/setup/global/vpcs.tf | aws | [
"aws_vpc"
] | c7312598780622b9b56d2412d3efa360 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a task definition for a Flask API running on AWS Fargate with 0.25 vCPU and 512 MB memory, using the latest image from a specific ECR repository, exposing port 5000, setting the environment to production, and sending logs to a CloudWatch Logs group named `/ecs/<project>` with the stream prefix `ecs`. | # ------------------------------------------------------------------------------
# ECS Task Definition
# This defines how your container will run on Fargate: CPU, memory, image, ports
# ------------------------------------------------------------------------------
resource "aws_ecs_task_definition" "app" {
family ... | lyn-boyu/aws-dev-ops | MIT | apps/flask-api-ecs-terraform/terraform/task_definition.tf | aws | [
"aws_ecs_task_definition"
] | 13016be8048584964a66f8dbf87c22fc |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a KMS key named “s3_bucket_event_notification_sns” with a 10-day deletion window and automatic key rotation enabled, and configure its resource policy to allow the S3 service to decrypt and generate data keys for encrypting S3 bucket event notifications, grant full permissions on the key to the account’s root us... | resource "aws_kms_key" "s3_bucket_event_notification_sns" {
description = "KMS Key for Encrypting S3 Bucket Event Notifications in SNS"
deletion_window_in_days = 10
policy = data.aws_iam_policy_document.s3_bucket_event_notification_sns.json
enable_key_rotation = true
}
data "aw... | ministryofjustice/opg-terraform-aws-account | MIT | modules/s3_bucket_event_notifications/kms.tf | aws | [
"aws_kms_key"
] | 746b32ca54b608b84c151c48149206a6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a centralized logging S3 bucket with versioning enabled, server-side encryption using either a specified KMS key or AES256, and public access fully blocked; configure a lifecycle policy that transitions all objects to Standard-IA after 90 days, to Glacier after 180 days, and expires them after 7 years. Separatel... | # ============================================================================
# Logging Module - CloudTrail, CloudWatch Logs, S3 Log Aggregation
# ============================================================================
data "aws_caller_identity" "current" {}
# ===================================================... | Htunn/tf-cloud-landing-zone | Apache-2.0 | modules/logging/main.tf | aws | [
"aws_cloudtrail",
"aws_cloudwatch_log_group",
"aws_iam_role",
"aws_iam_role_policy",
"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"
] | 14dfd4e790b335e071bf69c6e54482c0 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EC2 instance running Amazon Linux 2023 in the specified VPC, using the first available subnet with auto-assign public IP enabled, with a t3.small instance type, an SSH-accessible security group allowing inbound traffic on port 22 from anywhere, an IAM role and instance profile granting SSM access, and metadat... |
# Look up existing VPC
data "aws_vpc" "imported_vpc" {
id = var.vpc_id
}
# Find subnets with auto-assign public IP enabled
data "aws_subnets" "public_subnets" {
filter {
name = "vpc-id"
values = [var.vpc_id]
}
filter {
name = "map-public-ip-on-launch"
values = ["true"]
}
}
# Find late... | meghagupta109/clone_aws_gen_ai | MIT-0 | litellm-private-load-balancer-ec2-terraform/main.tf | aws | [
"aws_iam_instance_profile",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"aws_instance",
"aws_security_group"
] | fa1a78a291783642f50a8f0053e56fd2 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a Gateway VPC endpoint for S3 attached to the main VPC, and create five Interface VPC endpoints—for Amazon ECR Docker registry, ECR API, CloudWatch Logs, SSM messages, and KMS—each attached to the first private subnet, using the same security group, with private DNS enabled for all, and name each endpoint consis... | resource "aws_vpc_endpoint" "s3" {
vpc_id = aws_vpc.main.id
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"
vpc_endpoint_type = "Gateway"
tags = {
Name = "vpce-example-ecs-fargate-s3"
}
}
resource "aws_vpc_endpoint" "ecr_dkr" {
vpc_id = aws_vpc.main.id
service_name... | Donngi/terraform-example-ecs-fargate | MIT | terraform/modules/network/vpc_endpoint.tf | aws | [
"aws_vpc_endpoint"
] | 02aed5fba0ba7991e41575ea41f40bf5 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Configure CORS for the specified S3 bucket using the provided region, bucket name, and expected bucket owner, allowing dynamic CORS rules with customizable allowed headers, methods, origins, exposed headers, rule IDs, and maximum age in seconds. | resource "aws_s3_bucket_cors_configuration" "this" {
region = var.region
bucket = var.bucket
expected_bucket_owner = var.expected_bucket_owner
dynamic "cors_rule" {
for_each = var.cors_rule
content {
allowed_headers = cors_rule.value.allowed_headers
allowed_met... | ebogdum/terraform-providers | MIT | aws/resources/s3_bucket_cors_configuration/main.tf | aws | [
"aws_s3_bucket_cors_configuration"
] | c95e6dda12333186a0b1a3d80302c07a |
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 prefix “-syslog-container” in the specified VPC to support a syslog server, allowing inbound UDP and TCP traffic on port 514 and 5140 respectively from any source, outbound HTTPS traffic on port 443 to any destination, and inbound HTTP health checks on port 80 only from within the... | resource "aws_security_group" "syslog_server" {
name = "${var.prefix}-syslog-container"
description = "Allow the ECS agent to talk to the ECS endpoints"
vpc_id = var.vpc_id
tags = var.tags
}
resource "aws_security_group_rule" "syslog_container_web_out" {
description = "Allow SSL outbound c... | uk-gov-mirror/ministryofjustice.staff-device-logging-infrastructure | MIT | modules/syslog_endpoint/security_groups.tf | aws | [
"aws_security_group",
"aws_security_group_rule"
] | 180133476ccc6e07f6d99e9052300707 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a WAF Web ACL named “xss_WebACL_tf” that blocks cross-site scripting (XSS) attacks targeting the URI and query string fields, using a rule group named “xss_rule_group_tf” with the same XSS detection rule configured to count matches rather than block them, and ensure the ACL’s default action allows traffic unless... | resource "aws_waf_web_acl" "waf_acl" {
depends_on = [aws_waf_xss_match_set.xss_match_set, aws_waf_rule.wafrule]
name = "xss_WebACL_tf"
metric_name = "xssWebACLtf"
default_action {
type = "ALLOW"
}
rules {
action {
type = "BLOCK"
}
priority = 1
rule_id = aws_waf_rule.waf... | andrzejsydor/aws | Apache-2.0 | Terraform/WAF/main.tf | aws | [
"aws_waf_rule",
"aws_waf_rule_group",
"aws_waf_web_acl",
"aws_waf_xss_match_set"
] | 2c1d1a0aa278732f7d9704dfac55c2f9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an internet-facing Application Load Balancer named ALB in the VPC, attached to public subnets and secured by a specific security group; set up a target group named TargetGroup on port 80 using HTTP protocol with configurable health checks, and register exactly three Ubuntu instances as targets if three instances... | # Create Application Load balancer
resource "aws_lb" "lb" {
name = "ALB"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.igw_sg.id, ]
subnets = aws_subnet.public_subnets.*.id
}
# Create target group
resource "aws_lb_target_group"... | ugwulo/ec2-load-balancer | Apache-2.0 | alb.tf | aws | [
"aws_alb_target_group_attachment",
"aws_lb",
"aws_lb_listener",
"aws_lb_target_group"
] | 68276a3a7183beef154926c2d0ddce11 |
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, instance type, and availability zone, attach an SSH key and security group, configure a root volume of the requested size, include two ephemeral block devices (xvdb and xvdc) for compatibility with instance types that provide them, and inject user data from a local YAM... | resource "aws_instance" "instance" {
ami = var.ami
instance_type = var.instance_type
availability_zone = var.availability_zone
key_name = var.ssh_key_name
subnet_id = var.subnet_id
vpc_security_group_ids = [var.vpc_security_group_id]
root_block_... | cbron/scalability-tests | BSD-3-Clause | aws_host/main.tf | aws | [
"aws_instance",
"local_file",
"null_resource"
] | 8a0cfbcad5745a462158a0bb6cc60114 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a private S3 bucket named `data-4523432` with all public access blocked—including public ACLs, public policies, and bucket-wide public access—and upload a specific file `test_file.txt` as an object with the key `test_file.txt`, using its MD5 hash to ensure content integrity. | resource "aws_s3_bucket" "data" {
bucket = "data-4523432"
acl = "private"
}
resource "aws_s3_bucket_public_access_block" "data" {
bucket = aws_s3_bucket.data.id
block_public_acls = true
ignore_public_acls = true
block_public_policy = true
restrict_public_buckets = true
... | sastels/learn-AWS-terraform | MIT | Solutions Architect - Associate/6.13: Using EC2 Roles and Instance Profiles in AWS/s3.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_object",
"aws_s3_bucket_public_access_block"
] | d1485ff9f065e2f1f5df7573bd1aaa33 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SSM maintenance window target in the specified region, associated with the given maintenance window ID, with a configurable name, description, resource type, and owner information, and allow dynamic assignment of target resource groups using key-value pairs provided via the targets variable. | resource "aws_ssm_maintenance_window_target" "this" {
region = var.region
window_id = var.window_id
name = var.name
description = var.description
resource_type = var.resource_type
owner_information = var.owner_information
dynamic "targets" {
for_each = var.ta... | ebogdum/terraform-providers | MIT | aws/resources/ssm_maintenance_window_target/main.tf | aws | [
"aws_ssm_maintenance_window_target"
] | fd3ba02097ffd91cd31f7aadfd2fa5d7 |
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 environment variable suffixed by `-tf-pipeline-cb-role` that allows CodeBuild to assume it, attach a policy granting full access to CloudWatch Logs and S3, and provision one CodeBuild project per repository listed in the `repositories` variable—each named with the environment and repos... | variable "env" {}
variable "repositories" {}
resource "aws_iam_role" "codebuild_role" {
name = "${var.env}-tf-pipeline-cb-role"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Effect = "Allow",
Principal = {
Service = "codebuild.amazonaws.com"
},
Ac... | GagePielsticker/Terraform-Boilerplates | MIT | aws_project_codepipeline/modules/codebuild/main.tf | aws | [
"aws_codebuild_project",
"aws_iam_role",
"aws_iam_role_policy"
] | 540892c82543763e2a50f7f5e917a55e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group named “sg_test_sentinel” that allows inbound SSH access (TCP port 22) from any IP address on the internet, and tag it with the name “sg_test_sentinel”. | resource "aws_security_group" "sg_test_sentinel" {
name = "sg_test_sentinel"
description = "sg_test_sentinel"
ingress {
description = "ssh from internet"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "sg_test_sentinel"
}
... | munnep/tfc_aws_security_group | MIT | main.tf | aws | [
"aws_security_group"
] | 3f5da39fa9ffdc196f079267edb15b4b |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Fetch the current AWS Organizations structure, retrieve specific Identity Store groups and users by their display names and usernames respectively, locate the active AWS SSO instance, and fetch named permission sets—all while ensuring each data lookup waits for designated external dependencies to complete. | data "aws_organizations_organization" "o" {}
resource "null_resource" "sso_group_dependency" {
triggers = {
dependency_id = join(",", var.identitystore_group_depends_on)
}
}
resource "null_resource" "sso_user_dependency" {
triggers = {
dependency_id = join(",", var.identitystore_user_depends_on)
}
}
... | infraspecdev/terraform-aws-organizations | MIT | modules/account_users_and_groups_assignments/data.tf | aws | [
"null_resource"
] | 55c71e949db592a2f40cde97206a3082 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision an ECS cluster named “ecs-cluster” in the us-west-2 region, deploy a single Fargate task using 256 CPU units and 512 MB memory with an nginx:latest container exposing port 80, attach it to a service named “ecs-service” running in two specific subnets (subnet-12345678 and subnet-87654321), and create a securit... | provider "aws" {
region = "us-west-2"
}
resource "aws_ecs_cluster" "cluster" {
name = "ecs-cluster"
}
resource "aws_ecs_task_definition" "task" {
family = "ecs-task"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = "256"
memory ... | jco281/sampleIAC | MIT | infra/AWS/terraform/ecs/ecs_fargate_service/ecs_fargate_service.tf | aws | [
"aws_ecs_cluster",
"aws_ecs_service",
"aws_ecs_task_definition",
"aws_security_group"
] | 95918faaace499ab5f91866a551d8fa8 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a NAT instance with a single network interface in the specified subnet, disable source/destination checking on that interface, attach a public Elastic IP to it, and configure the instance using a launch template with a fixed AMI, instance type, and shared tags. | resource "aws_network_interface" "nat" {
subnet_id = local.nat_subnet_id
source_dest_check = false
security_groups = [aws_security_group.nat.id]
tags = local.tags
}
resource "aws_eip" "public_ip" {
network_interface = aws_network_interface.nat.id
tags = local.tags
}
res... | jetbrains-infra/terraform-aws-nat-instance | Apache-2.0 | launch_template.tf | aws | [
"aws_eip",
"aws_launch_template",
"aws_network_interface"
] | 1f8182747bb84b89150a0806037cf80e |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudFront distribution for a static website hosted in an S3 bucket, using an origin access identity to restrict direct S3 access, with HTTPS-only viewer protocol, a 1-second TTL for all caching, no cookie or query string forwarding, WAF protection via a specified ACL, logging to a designated S3 bucket, and a ... | variable "resource_prefix" {}
variable "s3_bucket_log_domain_name" {}
variable "s3_bucket_web_id" {}
variable "s3_bucket_web_domain_name" {}
variable "waf_acl_id" {}
resource "aws_cloudfront_origin_access_identity" "web" {
comment = "access-identity-${var.s3_bucket_web_domain_name}"
}
resource "aws_cloudfront_distr... | nihemak/aws-sls-spa-sample-terraform | MIT | modules/cloudfront/web/main.tf | aws | [
"aws_cloudfront_distribution",
"aws_cloudfront_origin_access_identity"
] | c88d511ebc08b2c0e88eabc7f53ebe89 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC named “Attacker VPC” with a /16 CIDR block, enable DNS hostnames, and provision a public subnet with a /24 CIDR block. Attach an internet gateway to the VPC, create a route table with a default route (0.0.0.0/0) pointing to the internet gateway, and associate the subnet with this route table. Launch a Kali... | resource "aws_vpc" "vpc_attacker" {
cidr_block = "20.0.0.0/16"
enable_dns_hostnames = true
tags = {
Name = "Attacker VPC"
}
}
resource "aws_subnet" "public_subnet_attacker" {
vpc_id = aws_vpc.vpc_attacker.id
cidr_block = "20.0.1.0/24"
tags = {
Name = "Public Subnet of Attacker VP... | terlbrown/detection-lab | MIT | scripts/network_02.tf | aws | [
"aws_instance",
"aws_internet_gateway",
"aws_route",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | bf36fae4c56e52a096d1e9f10846c133 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a CloudWatch log group named `/ecs/<cluster_name>/<name>` with a configurable log retention period in days and a tag `ExportToS3` set to a boolean value determining whether logs should be exported to S3. | resource "aws_cloudwatch_log_group" "default" {
name = "/ecs/${var.cluster_name}/${var.name}"
retention_in_days = var.cloudwatch_logs_retention
tags = {
ExportToS3 = var.cloudwatch_logs_export
}
} | DNXLabs/terraform-aws-ecs-app-worker | Apache-2.0 | cloudwatch-logs.tf | aws | [
"aws_cloudwatch_log_group"
] | 9d265c642817658ebf1cec9309d0a759 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Generate a random password exactly 16 characters long using only the special characters !@#$%^&*()_+ and no other special characters. | resource "random_password" "example" {
length = 16
special = true
override_special = "!@#$%^&*()_+"
} | conorkent/HCP-TF-04-Ops-TF | MIT | terraform/random.tf | aws | [
"random_password"
] | f17f65671f5cfa2a0730c15fc991f695 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a private S3 object named `lambda_package.zip` in the bucket `s3_bucket_lambda_package` using the file path provided via the `upload_file` variable, and ensure the object is automatically deleted if the bucket is destroyed. | # upload zip to s3 and then update lamda function from s3
resource "aws_s3_object" "lambda_package" {
bucket = "s3_bucket_lambda_package"
key = "lambda_package.zip"
#source = archive_file("path/to/lambda_package", "zip")
source = var.upload_file
acl = "private"
force_destroy = true
} | cloudsheger/terraform-lambda-efs | MIT-0 | modules/s3_bucket/main.tf | aws | [
"aws_s3_object"
] | f6df125bffe96a8e27ff7a346cc3cfdf |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an AWS Data Exchange revision with assets sourced from one or more S3 buckets (using either full object keys, key prefixes, or signed URLs), specifying the data set ID, AWS region, an optional revision comment, whether to finalize the revision, whether to force deletion of associated resources, and custom tags; ... | resource "aws_dataexchange_revision_assets" "this" {
data_set_id = var.data_set_id
dynamic "asset" {
for_each = var.asset
content {
dynamic "create_s3_data_access_from_s3_bucket" {
for_each = asset.value.create_s3_data_access_from_s3_bucket != null ? [asset.value.create_s3_data_access_from_s3... | ebogdum/terraform-providers | MIT | aws/resources/dataexchange_revision_assets/main.tf | aws | [
"aws_dataexchange_revision_assets"
] | cda548e4841e9480d5e83df6eb791bf9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an S3 bucket with the name provided via the `bucket_name` variable, enable versioning, block all public access including ACLs, policies, and bucket restrictions, encrypt all objects using AES256 server-side encryption, and attach a bucket policy that grants the CloudFront origin access identity permission to ret... | #
# S3 bucket origin
#####################################
resource "aws_s3_bucket" "origin" {
#checkov:skip=CKV_AWS_18: "Ensure the S3 bucket has access logging enabled" - enabled on CloudFront
#checkov:skip=CKV_AWS_144: "Ensure that S3 bucket has cross-region replication enabled" - not required in our case
#c... | nbekenov/angular-app-in-s3 | MIT | infra/modules/cloudfront-s3-cdn/s3_origin.tf | aws | [
"aws_s3_bucket",
"aws_s3_bucket_policy",
"aws_s3_bucket_public_access_block",
"aws_s3_bucket_server_side_encryption_configuration",
"aws_s3_bucket_versioning"
] | e0ddb066c766c71aa94e89e0b82a676d |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a unique policy attachment name prefixed with “policy-attachment” that changes whenever the list of policies, roles, users, or groups changes, using a three-word random identifier separated by hyphens; then attach each policy in the provided list to all specified users, roles, and groups, one attachment per poli... | resource "random_pet" "this" {
prefix = "policy-attachment"
keepers = {
# Generate a new pet name each time we switch to a new AMI id
policies = join(",",var.policies)
roles = join(",",var.roles)
users = join(",",var.users)
groups = join(",",var.groups)
}
length = 3
separator = "-"
}
reso... | diegotony/aws_policy | MIT | main.tf | aws | [
"aws_iam_policy_attachment",
"random_pet"
] | 2ba7df1bb46c34893ccaa32894a0f1fe |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create multiple SSM Parameters from a list of input definitions, where parameters marked to ignore value changes are created with a lifecycle rule that prevents Terraform from detecting future value modifications, while parameters not marked to ignore value changes are created normally without that lifecycle protection... | resource "aws_ssm_parameter" "ssm_parameter" {
for_each = { for ssm_parameter in var.parameters : ssm_parameter.name => ssm_parameter if ssm_parameter.ignore_value }
name = each.value.name
type = each.value.type
value = each.value.value
description = each.value.description
tier ... | nationalarchives/da-terraform-modules | MIT | ssm_parameter/main.tf | aws | [
"aws_ssm_parameter"
] | 3365fa53d978d70f8642ea19f9fd77e9 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a VPC in us-east-1 with a 10.0.0.0/16 CIDR block, enable DNS support and hostnames, attach an internet gateway, and configure a public route table that routes all traffic (0.0.0.0/0) to the internet gateway. Launch one public subnet in the first available Availability Zone with a 10.0.1.0/24 CIDR block, associat... | #-----vpc/main.tf-----
#======================
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = var.region
}
#Get all available AZ's in VPC for this region
#================================================
data "aws_availability_zon... | justin-irl/CSDO1010-007-B-W24-TEMPLATE | MIT | modules/vpc/main.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_security_group",
"aws_subnet",
"aws_vpc"
] | f5f0ecdb0d753b1d2f1caee39bab6ccf |
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, attach an internet gateway, and provision three public subnets across three availability zones—each associated with a route table that routes all traffic (0.0.0.0/0) to the internet gateway—plus three private subnets, one in each availability zone. | resource "aws_vpc" "vpc" {
cidr_block = local.cidr_vpc
instance_tenancy = "default"
enable_dns_support = true
enable_dns_hostnames = true
tags = {
Name = "${local.name}-vpc"
}
}
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.vpc.id
tags = {
Name = "${local.name}-igw"... | dnvriend/study-aws-hyderabad | Apache-2.0 | network.tf | aws | [
"aws_internet_gateway",
"aws_route_table",
"aws_route_table_association",
"aws_subnet",
"aws_vpc"
] | 5b94c9a08bf360f96335c742a7b337f1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an SQS queue named “InboundRemediations” and attach a policy that allows a specific IAM role or user—identified by the ARN stored in `local.queue_principal_arn`—to send messages to it. | resource "aws_sqs_queue_policy" "InboundRemediations" {
policy = jsonencode(
{
Statement = [
{
Action = "SQS:SendMessage"
Effect = "Allow"
Principal = {
AWS = local.queue_principal_arn
}
Resource = aws_sqs_queue.InboundRemediations.arn
... | bridgecrewio/terraform-aws-bridgecrew-remediation | Apache-2.0 | aws_sqs_queuepolicy.InboundRemediations.tf | aws | [
"aws_sqs_queue_policy"
] | c0da258f6847300aaa994030da47f7e4 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a security group in the specified VPC named “SSHOnlySecurityGroup” that permits SSH (port 22) and RDP (port 3389) access only from my IPv6 address, while allowing all outbound IPv6 traffic. Generate a 4096-bit RSA key pair named “ssh-simple-ec2-key-pair” and save the private key locally as “simple-ec2-key.pem” i... | # Create a Security Group that Only Allows SSH from My IPv6
resource "aws_security_group" "sg" {
vpc_id = var.vpc_id
name = "SSH-Only SG"
description = "SSH-Only from my IP"
# not the best practice, but simple enough for testing
ingress {
from_port = 22
to_port = 22
pr... | Evan-YJ-Zhao/simple-ec2-terraform-template | MIT | modules/ec2/main.tf | aws | [
"aws_instance",
"aws_key_pair",
"aws_security_group",
"local_file",
"tls_private_key"
] | 8ece9204b3fdee44b0b16d57d89451ea |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named `ecs_express_infrastructure_role` that Amazon ECS can assume to manage infrastructure, attach the AWS-managed `AmazonECSInfrastructureRoleforExpressGatewayServices` policy, and add a custom inline policy allowing EC2 describe actions on VPCs, subnets, security groups, network interfaces, and av... |
resource "aws_iam_role" "infrastructure" {
name = "ecs_express_infrastructure_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "ecs.amazonaws.com"
}
}
... | aws-samples/sample-ecs-express-starter-kit | MIT-0 | iac/ecs_roles.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy",
"aws_iam_role_policy_attachment"
] | 0a3fa0454024cb18646cf07c80de56f1 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Launch a single EC2 instance named `ec2_basic` using Amazon Linux 2 (AMI ID `ami-00056a28d6c5e916b`), configured as a `t2.micro` instance, connected to a specific security group and using the SSH key pair named `macbook_air_ubuntu`. | resource "aws_instance" "ec2_basic" {
ami = "ami-00056a28d6c5e916b"
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.ec2_basic.id]
key_name = aws_key_pair.macbook_air_ubuntu.key_name
} | DonaldKellett/iac-intro-terraform-packer | MIT | ec2-basic/instance.tf | aws | [
"aws_instance"
] | 63a1d665ed0fdc0d340c30ee8972a277 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an EKS cluster with Fargate profiles for the default, argo-rollouts, and kube-system namespaces, using shared subnets tagged for the cluster, and attach the AWS-managed EKS Fargate pod execution policy to a role named after the cluster with Fargate pod assume role permissions; then, after the kube-system Fargate... | terraform {
required_providers{
aws ={
source = "hashicorp/aws"
configuration_aliases = [ aws ]
}
}
}
resource "aws_iam_role" "eks-fargate-profile" {
name = "${var.EKS-cluster.name}-fargate-profile"
assume_role_policy = jsonencode({
Statement = [{
Action = "sts:AssumeRole"
... | yasirub/clouda-saas | Apache-2.0 | MVP_Blue_Green_Deployment_ArgoRollouts/FargateProfile_config/main.tf | aws | [
"aws_eks_fargate_profile",
"aws_iam_role",
"aws_iam_role_policy_attachment",
"null_resource"
] | c5bda478b2c1e8d44fe908c89a96f640 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a custom KMS key with a configurable description, a deletion window of 30 days, and key rotation enabled; configure its policy to grant full permissions to the account root, allow EC2, Auto Scaling, EKS, ECS, and RDS services to encrypt, decrypt, and manage grants for EBS volumes, and restrict access through EBS... | # https://aquasecurity.github.io/tfsec/v1.28.13/checks/aws/ebs/encryption-customer-key/
resource "aws_kms_key" "this" {
count = local.create_custom_kms_key ? 1 : 0
description = local.kms_key_description
deletion_window_in_days = local.kms_key_deletion_window
enable_key_rotation = local.enable_... | itsregularjohn/terraform-aws-enterprise-eks | MIT | accounts/production/us-east-1/00-ebs-encryption/kms.tf | aws | [
"aws_kms_alias",
"aws_kms_key"
] | 13ea229385619f6a7933e0ca33322b66 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a set of security groups, one for each tier specified in the input variable, all associated with the given VPC and tagged with the provided name prefix and common tags; for each defined rule, add matching ingress and egress rules between the source and destination tiers using security group references, allowing ... | locals {
tier_set = toset(var.tiers)
}
resource "aws_security_group" "tier" {
for_each = local.tier_set
name = "${var.name_prefix}-sg-${each.key}"
description = "Tier security group for ${each.key}"
vpc_id = var.vpc_id
tags = merge(var.tags, {
Name = "${var.name_prefix}-sg-${each.key}"
... | Nisha318/cloud-network-segmentation | MIT | infra/terraform/modules/security_groups/main.tf | aws | [
"aws_security_group",
"aws_security_group_rule"
] | b95cf84146d5765bcba6dcc9ed6be14c |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role policy named with the prefix `_DeveloperBoxRolePolicy` that attaches a JSON policy template rendered with the prefix, environment, region, account ID, and bucket name variables to the `developer_box_role` IAM role. | data "template_file" "policy" {
template = file("${path.module}/json/policy.json")
vars = {
prefix = var.prefix
environment = var.environment
region = var.region
account_id = var.account_id
bucket_name = var.bucket_name
}
}
resource "aws_iam_role_policy" "developer_box_role_policy... | alphagov/csw-infra | MIT | modules/developer_box_role/policy.tf | aws | [
"aws_iam_role_policy"
] | 0b444183214b68b2ad803d24615bb718 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create an IAM role named according to the `service_account_role.name` variable, configured to allow Kubernetes service accounts in a specific namespace and name (or any service account if the name is wildcarded) to assume the role via OIDC federation, with a maximum session duration of 3600 seconds unless overridden, a... | locals {
max_session_duration = lookup(var.service_account_role, "max_session_duration", 3600)
}
data "aws_iam_policy_document" "trust_policy" {
statement {
sid = "1"
actions = ["sts:AssumeRoleWithWebIdentity"]
principals {
type = "Federated"
identifiers = [var.oidc_arn]
}
... | opendatacube/datacube-k8s-eks | Apache-2.0 | odc_k8s_service_account_role/role.tf | aws | [
"aws_iam_role",
"aws_iam_role_policy"
] | c1a97c66a0c5bc235c5072b6dbda9361 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Provision a t2.micro EC2 instance in the ap-southeast-1 region using AMI ami-02a45d709a415958a, configure it to start a Python HTTP server on port 8080 at boot, assign it a security group named terraform-example-instance that allows inbound TCP traffic on ports 8080 and 22 from any IPv4 address, and expose the instance... | terraform {
required_providers {
aws = {
# Allow any 2.x version of the AWS provider
}
}
}
provider "aws" {
region = "ap-southeast-1"
}
resource "aws_instance" "example" {
ami = "ami-02a45d709a415958a"
instance_type = "t2.micro"
vpc_security_group_ids = [aws_secu... | softarts/aws_practice | Apache-2.0 | terraform/singleserver/main.tf | aws | [
"aws_instance",
"aws_security_group"
] | 3a9a8b50de0a46f3f9c69c500449ff80 |
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 variable `var.name`, exposed to the internet, with deletion protection enabled, idle timeout of 60 seconds, and invalid header fields dropped; attach it to public subnets and a custom security group. Configure a target group on port 8080 using HTTP protocol, targeting... | #https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb
resource "aws_lb" "app_lb" {
#checkov:skip=CKV_AWS_91: Access logging is disabled since this is non-prod.
#checkov:skip=CKV2_AWS_20: This is disabled since this is non-prod.
#checkov:skip=CKV2_AWS_28: This is disabled since this is no... | kunduso/add-aws-ecr-ecs-fargate | Unlicense | infra/load_balancer.tf | aws | [
"aws_alb_listener",
"aws_lb",
"aws_lb_target_group"
] | 0c2250752408a9b49bb48175e97bd808 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a load balancer target group with a name derived from a variable, or a six-character prefix if provided, configured for a specific port and protocol in a given VPC, with optional health checks specifying path, timeout, matcher, interval, protocol, and thresholds, optional stickiness with type and cookie settings... | resource "aws_lb_target_group" "this" {
name = var.name
name_prefix = try(substr(var.name_prefix,0,6), null)
port = var.port
protocol = var.protocol
vpc_id = var.vpc_id
target_type = var.target_type
dynamic "health_check" {
for_each = var.health_check != null ? [1] : []
cont... | bryan-rhm/terraform-aws-alb-target-group | Apache-2.0 | main.tf | aws | [
"aws_lb_target_group"
] | 3eb898f5317a1a415e191dc4b70f67a6 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Set up a public static website for vsubtle.com using an S3 bucket named vsubtle.com configured for website hosting, upload index.html, style.css, and logic.js files to it, and make the bucket fully public. Register the domain vsubtle.com via Route 53 and create both IPv4 (A) and IPv6 (AAAA) records pointing to a CloudF... | terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = "us-east-1"
}
data "aws_iam_policy_document" "web_hosting_policy" {
statement {
sid = "PublicReadGetObject"
principals {
identifiers = ["*"]
type = "*"
}
action... | vernellm/cloud-resume-challenge | MIT | backend/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_cloudfront_distribution",
"aws_dynamodb_table",
... | a725055aa1f5281d49ad71793ae35653 |
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 derived from a variable, a minimal trust policy that allows no services to assume it, and tags applied consistently using a shared local tags map. | resource "aws_iam_role" "example_resource" {
name = var.name # <= You may need to append to the name string in a name field to avoid conflicts
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
]
}
EOF
tags = local.tags # <= Note the use of local.tags
} | fernandoPedraza-sg/terraform-aws-site-to-site-vpn | Apache-2.0 | main.tf | aws | [
"aws_iam_role"
] | 0942847d9ee1f6ac36f8b7f0d3252429 |
Write a Terraform configuration for AWS that satisfies the requirement below. Emit only HCL — no explanation, no markdown fences. | Create a KMS key for encrypting CloudWatch logs of a CodeBuild project, named with the project’s name and suffixed with `-cloudwatch`, with key rotation enabled every 90 days and a 30-day deletion window; grant the TerraformApplier and KmsAdministrator full KMS management permissions, additional read-only roles (Terraf... | locals {
arnformat = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/%s"
}
data "aws_iam_policy_document" "cloudwatch" {
statement {
sid = "AllowKeyManagement"
principals {
type = "AWS"
identifiers = formatlist(local.arnformat, [
"RoleTerraformApplier",
"RoleKms... | hmrc/platsec-ci-terraform | Apache-2.0 | modules/codebuild/cloudwatch.tf | aws | [
"aws_cloudwatch_log_group",
"aws_kms_alias",
"aws_kms_key"
] | cf7270afe1e64895a99c5f1e7baa7405 |
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 named after the project, attached to the specified VPC, that allows inbound HTTP and HTTPS traffic from the entire internet, and permits outbound TCP traffic on port 2283 to the ECS application security group. | resource "aws_security_group" "alb_sg" {
name = "${var.project_name}-alb-sg"
vpc_id = var.vpc_id
tags = {
Name = "${var.project_name}-ALB-SG"
}
}
resource "aws_security_group_rule" "alb_inbound_http" {
description = "Allow HTTP traffic from Internet"
security_group_id = aws_security_group.alb_sg.id
... | ronchese66/devops-lab | MIT | infrastructure/terraform/modules/alb/security_groups.tf | aws | [
"aws_security_group",
"aws_security_group_rule"
] | 8969bdfe9aec4ea470e58c930a7d6d92 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.