This file contains 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
locals { | |
api_name = var.environment == "prod" ? "api" : "api-${var.environment}" | |
} | |
resource "aws_acm_certificate" "cert" { | |
domain_name = var.domain_name | |
validation_method = "DNS" | |
subject_alternative_names = ["www.${var.domain_name}"] | |
} |
This file contains 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 "random_pet" "ebs_bucket_name" {} | |
resource "aws_s3_bucket" "ebs" { | |
bucket = "${local.common_name}-${random_pet.ebs_bucket_name.id}" | |
} | |
data "template_file" "ebs_config" { | |
template = file("${path.module}/Dockerrun.aws.json.tpl") | |
vars = { | |
image_name = var.acr_repository_url |
This file contains 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
{ | |
"AWSEBDockerrunVersion": "1", | |
"Image": { | |
"Name": "${image_name}", | |
"Update": "true" | |
}, | |
"Ports": [ | |
{ | |
"ContainerPort": "1323", | |
"HostPort": "1323" |
This file contains 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
FROM golang:1.20 AS builder | |
WORKDIR /go/src/github.com/path/to/your/code | |
COPY go.mod go.mod | |
COPY go.sum go.sum | |
RUN go mod download | |
COPY main.go main.go |
This file contains 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
#!/bin/bash | |
docker build -t $ECR_URL/$ECR_NAME:latest | |
aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ECR_URL | |
docker push $ECR_URL/$ECR_NAME:latest |
This file contains 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_ecr_repository" "app" { | |
name = local.common_name | |
image_tag_mutability = "MUTABLE" | |
image_scanning_configuration { | |
scan_on_push = true | |
} | |
} |
This file contains 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_acm_certificate" "cert" { | |
domain_name = var.domain_name | |
validation_method = "DNS" | |
subject_alternative_names = ["www.${var.domain_name}"] | |
} | |
data "aws_route53_zone" "zone" { | |
name = var.route53_zone_name | |
private_zone = false | |
} |
This file contains 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
data "http" "myip" { | |
url = "http://ipv4.icanhazip.com" | |
} | |
resource "aws_security_group" "ebs" { | |
name = "${local.common_name}-ebs" | |
vpc_id = var.vpc_id | |
# for ssh | |
ingress { | |
from_port = 22 |
This file contains 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
locals { | |
api_name = var.environment == "prod" ? "api" : "api-${var.environment}" | |
} | |
module "certificate" { | |
source = "../certificates" | |
domain_name = "${local.api_name}.${var.domain_name}" | |
route53_zone_name = var.route53_zone_name | |
region = "us-west-2" | |
} |
This file contains 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_iam_role" "ebs" { | |
name = "${local.common_name}-ebs" | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { |
NewerOlder