This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Database: | |
| Type: AWS::RDS::DBInstance # (1) | |
| Properties: | |
| VPCSecurityGroups: | |
| - !Ref DbSecurityGroup # (2) | |
| AllocatedStorage: "10" | |
| DBSubnetGroupName: !Ref DbSubnetGroup # (3) | |
| DBInstanceClass: "db.t2.micro" | |
| Engine: "postgres" | |
| MasterUsername: Username |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AWSTemplateFormatVersion: 2010-09-09 | |
| Resources: | |
| VPC: | |
| Type: AWS::EC2::VPC | |
| Properties: | |
| CidrBlock: 10.0.0.0/16 | |
| PublicSubnetA: | |
| Type: AWS::EC2::Subnet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| provider "aws" { | |
| version = "~> 2.0" | |
| region = "eu-west-2" # Setting my region to London. Use your own region here | |
| } | |
| resource "aws_ecr_repository" "my_first_ecr_repo" { | |
| name = "my-first-ecr-repo" # Naming my repository | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "aws_ecs_cluster" "my_cluster" { | |
| name = "my-cluster" # Naming the cluster | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "aws_ecs_task_definition" "my_first_task" { | |
| family = "my-first-task" # Naming our first task | |
| container_definitions = <<DEFINITION | |
| [ | |
| { | |
| "name": "my-first-task", | |
| "image": "${aws_ecr_repository.my_repo.repository_url}", | |
| "essential": true, | |
| "portMappings": [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "aws_ecs_task_definition" "my_first_task" { | |
| family = "my-first-task" # Naming our first task | |
| container_definitions = <<DEFINITION | |
| [ | |
| { | |
| "name": "my-first-task", | |
| "image": "${aws_ecr_repository.my_first_ecr_repo.repository_url}", | |
| "essential": true, | |
| "portMappings": [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # General setup | |
| provider "aws" { | |
| version = "~> 2.0" | |
| region = "eu-west-2" # Setting our region | |
| } | |
| # Providing a reference to our default VPC | |
| resource "aws_default_vpc" "default_vpc" { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "aws_ecs_service" "my_first_service" { | |
| name = "my-first-service" # Naming our first service | |
| cluster = "${aws_ecs_cluster.my_cluster.id}" # Referencing our created Cluster | |
| task_definition = "${aws_ecs_task_definition.my_first_task.arn}" # Referencing the task our service will spin up | |
| launch_type = "FARGATE" | |
| desired_count = 3 # Setting the number of containers we want deployed to 3 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Providing a reference to our default VPC | |
| resource "aws_default_vpc" "default_vpc" { | |
| } | |
| # Providing a reference to our default subnets | |
| resource "aws_default_subnet" "default_subnet_a" { | |
| availability_zone = "eu-west-2a" | |
| } | |
| resource "aws_default_subnet" "default_subnet_b" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "aws_ecs_service" "my_first_service" { | |
| name = "my-first-service" # Naming our first service | |
| cluster = "${aws_ecs_cluster.my_cluster.id}" # Referencing our created Cluster | |
| task_definition = "${aws_ecs_task_definition.my_first_task.arn}" # Referencing the task our service will spin up | |
| launch_type = "FARGATE" | |
| desired_count = 3 # Setting the number of containers we want deployed to 3 | |
| network_configuration { | |
| subnets = ["${aws_default_subnet.default_subnet_a.id}", "${aws_default_subnet.default_subnet_b.id}", "${aws_default_subnet.default_subnet_c.id}"] | |
| assign_public_ip = true # Providing our containers with public IPs |