Skip to content

Commit 6f9893a

Browse files
committed
chore: adiciona config do api gateway + authorizer
1 parent 4055dbc commit 6f9893a

File tree

5 files changed

+73
-18
lines changed

5 files changed

+73
-18
lines changed

agw/apw.tf

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module "api_gateway_security_group" {
2+
source = "terraform-aws-modules/security-group/aws"
3+
version = "~> 5.0"
4+
5+
name = "api-gateway-security-group"
6+
description = "API Gateway group for example usage"
7+
vpc_id = var.vpc_id
8+
9+
ingress_cidr_blocks = ["0.0.0.0/0"]
10+
ingress_rules = ["http-80-tcp"]
11+
12+
egress_rules = ["all-all"]
13+
}
14+
15+
module "api_gateway" {
16+
source = "terraform-aws-modules/apigateway-v2/aws"
17+
18+
# API
19+
cors_configuration = {
20+
allow_headers = ["content-type", "x-amz-date", "authorization", "x-api-key", "x-amz-security-token", "x-amz-user-agent"]
21+
allow_methods = ["*"]
22+
allow_origins = ["*"]
23+
}
24+
25+
description = "HTTP API Gateway with VPC links"
26+
name = "api-gateway-tech-challenge"
27+
28+
# Custom Domain
29+
create_domain_name = false
30+
31+
authorizers = {
32+
"lambda" = {
33+
authorizer_type = "REQUEST"
34+
enable_simple_responses = true
35+
identity_sources = ["$request.header.Authorization"]
36+
name = "lambda-auth"
37+
authorizer_uri = var.lambda_auth
38+
authorizer_payload_format_version = "2.0"
39+
}
40+
}
41+
42+
# Routes & Integration(s)
43+
routes = {
44+
"$default" = {
45+
authorizer_key = "lambda-auth"
46+
47+
integration = {
48+
connection_type = "INTERNET"
49+
type = "HTTP_PROXY"
50+
uri = var.cluster_uri
51+
method = "ANY"
52+
}
53+
}
54+
}
55+
}

agw/envs/dev/vars.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vpc_id = "vpc-000959e41b8306575"
2+
cluster_uri = "http://k8s-ingressn-external-32d23741d8-d3d2a1020869e40e.elb.us-east-1.amazonaws.com"
3+
lambda_auth="arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:872515278821:function:tech-challenge-custom-auth-AuthFunction-krBTkI88mWH6/invocations"

agw/vars.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
variable "vpc_id" {
2+
description = "VPC ID"
3+
type = string
4+
}
5+
6+
variable "cluster_uri" {
7+
description = "Cluster endpoint"
8+
type = string
9+
}
10+
11+
variable "lambda_auth" {
12+
description = "Lambda authorizer ARN"
13+
type = string
14+
}

terraform/03_ecr.tf

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@ module "ecr" {
44

55
repository_read_write_access_arns = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/admin"]
66
repository_name = var.ecr_repository_name
7-
repository_lifecycle_policy = jsonencode({
8-
rules = [
9-
{
10-
rulePriority = 1,
11-
description = "Keep last 15 images",
12-
selection = {
13-
tagStatus = "tagged",
14-
tagPrefixList = ["v"],
15-
countType = "imageCountMoreThan",
16-
countNumber = 15
17-
},
18-
action = {
19-
type = "expire"
20-
}
21-
}
22-
]
23-
})
247

258
tags = local.tags
269
}

terraform/envs/dev/backend.tfvars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bucket="pos-tech-chllange-tfstate"
1+
bucket="pangolin-tech-challenge-tfstate"
22
key="terraform.tfstate"
33
region="us-east-1"
44
dynamodb_table="tech-chllange-tfstate"

0 commit comments

Comments
 (0)