# Specify the provider and access details provider "aws" { region = "${var.aws_region}" } # Create a VPC to launch our instances into resource "aws_vpc" "default" { cidr_block = "10.0.0.0/16" } # Create an internet gateway to give our subnet access to the outside world resource "aws_internet_gateway" "default" { vpc_id = "${aws_vpc.default.id}" } # Grant the VPC internet access on its main route table resource "aws_route" "internet_access" { route_table_id = "${aws_vpc.default.main_route_table_id}" destination_cidr_block = "0.0.0.0/0" gateway_id = "${aws_internet_gateway.default.id}" } # Declare the data source data "aws_availability_zones" "available" {} # Create a subnet to launch our instances into resource "aws_subnet" "default" { vpc_id = "${aws_vpc.default.id}" cidr_block = "10.0.1.0/24" map_public_ip_on_launch = true } # Create a subnet to launch our instances into resource "aws_subnet" "default_2" { vpc_id = "${aws_vpc.default.id}" cidr_block = "10.0.2.0/24" map_public_ip_on_launch = true availability_zone = "${data.aws_availability_zones.available.names[0]}" } resource "aws_subnet" "default_3" { vpc_id = "${aws_vpc.default.id}" cidr_block = "10.0.3.0/24" map_public_ip_on_launch = true availability_zone = "${data.aws_availability_zones.available.names[1]}" } # A security group for the ELB so it is accessible via the web resource "aws_security_group" "elb" { name = "artifactory_elb" description = "Used in the terraform" vpc_id = "${aws_vpc.default.id}" # HTTP access from anywhere ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } # HTTPS access from anywhere ingress { from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } # outbound internet access egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } } #IAM user for S3 resource "aws_iam_user" "s3" { name = "s3-access" } #IAM access key for S3 resource "aws_iam_access_key" "s3" { user = "${aws_iam_user.s3.name}" } # S3 bucket resource "aws_s3_bucket" "b" { bucket = "${var.bucket_name}" acl = "private" } #IAM Policy resource "aws_iam_user_policy" "lb_ro" { user = "${aws_iam_user.s3.name}" policy = <