Skip to content

Commit

Permalink
feat: add API GW
Browse files Browse the repository at this point in the history
  • Loading branch information
flavono123 committed Sep 13, 2023
1 parent 34334d9 commit e8e6d1e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
terraform.tfstate
terraform.tfstate*
planfile
.pluralith
28 changes: 28 additions & 0 deletions serverless-workshop/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ terraform {
}
}

locals {
apigateway = {
api_name = "delivery-api"
stage_name = "dev"
}
}

# cf2tf <(wget -qO- https://static.us-east-1.prod.workshops.aws/public/ebdd2af6-e669-4dd3-99bd-c9de7921832e/assets/serverless-lab-cf.yaml)
# wrap assume_role_policy in jsonencode
data "aws_partition" "current" {}
Expand All @@ -32,3 +39,24 @@ resource "aws_iam_role" "apigwdeliveryorderrole_f75_cf62_c" {
]
name = "apigw-delivery-order-role"
}

## API Gateway

### API
resource "aws_apigatewayv2_api" "delivery_api" {
name = local.apigateway.api_name
protocol_type = "HTTP"
}


### Deploy/Stages
resource "aws_apigatewayv2_stage" "default" {
api_id = aws_apigatewayv2_api.delivery_api.id
name = "$default"
auto_deploy = true
}
resource "aws_apigatewayv2_stage" "dev" {
api_id = aws_apigatewayv2_api.delivery_api.id
name = local.apigateway.stage_name
auto_deploy = true
}
4 changes: 4 additions & 0 deletions serverless-workshop/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## API Gateway
output "apigatewayv2_api_endpoint" {
value = aws_apigatewayv2_api.delivery_api.api_endpoint
}

0 comments on commit e8e6d1e

Please sign in to comment.