vicuna-13b· LMSYS
Arena Human Preference 55K
write a terraform project to deploy a full stack web app on aws use ecs for backend,…
- User
write a terraform project to deploy a full stack web app on aws use ecs for backend, cloud front+s3 for frontend, rds postgres
- Assistant
# Configure the AWS provider provider "aws" { region = "us-west-2" } # Create a VPC resource "aws_vpc" "example" { cidr_block = "10.0.0.0/16" } # Create a subnet resource "aws_subnet" "example" { vpc_id = aws_vpc.example.id cidr_block = "10.0.1.0/24" } # Create an ECS cluster resource "aws_ecs_cluster" "example" { name = "example" } # Create an ECS task definition resource "aws_ecs_task_definition" "example" { family = "example" requires_compatibilities = ["FARGATE"] network_mode = "awsvpc" cpu = "2048" memory = "4096" execution_role_arn = aws_iam_role.example.arn task_role_arn = aws_iam_role.example.arn container_definitions = jsonencode([{ name = "example" image = "nginx" cpu = 2048 memory = 4096 essential = true portMappings = [{ containerPort = 80 hostPort = 80 protocol = "tcp" }] }]) } # Create an ECS service resource "aws_ecs_service" "example" { name = "example" cluster = aws_ecs_cluster.example.name task_definition = aws_ecs_task_definition.example.arn desired_count = 2 launch_type = "FARGATE" } # Create an S3 bucket resource "aws_s3_bucket" "example" { bucket = "example.com" } # Create a CloudFront distribution resource "aws_cloudfront_distribution" "example" { origin_configs = [{ origin_path = "index.html" custom_origin_config = { http_port = 80 https_port = 443 origin_protocol_policy = "https-only" origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"] } origin_id = "S3-bucket" s3_bucket_names = [aws_s3_bucket.example.id] }] enabled = true is_ipv6_enabled = true comment = "CloudFront distribution for example.com" default_root_object = "index.html" price_class = "PriceClass_All" default_cache_behavior = [{ allowed_methods = ["HEAD", "GET", "OPTIONS"] cached_methods = ["HEAD", "GET", "OPTIONS"] target_origin_id = "S3-bucket" forwarded_values = { query_string = false cookies = { forward = "none" } } viewer_protocol_policy = "redirect-to-https" min_ttl = 0 default_ttl = 3600 max_ttl = 86400 }] restrictions = { geo_restriction { restriction_type = "none" } } } # Create an RDS Postgres instance resource "aws_db_instance" "example" { instance_class = "db.t3.micro" engine = "postgres" engine_version = "11.12" username = "example" password = "example" database = "example" subnet_group_name = aws_db_subnet_group.example.name vpc_security_group_ids = [
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.