-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-gateway.tf
48 lines (42 loc) · 1.66 KB
/
api-gateway.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Configure the API gateway account
resource "aws_api_gateway_account" "account_settings" {
cloudwatch_role_arn = aws_iam_role.api_gateway_cloudwatch_role.arn
depends_on = [
aws_iam_role_policy_attachment.api_gateway_cloudwatch_logs_policy
]
}
resource "aws_api_gateway_rest_api" "sms-api" {
name = "smsnotification"
description = "API Gateway for SMS notification"
}
resource "aws_api_gateway_resource" "sms" {
rest_api_id = aws_api_gateway_rest_api.sms-api.id
parent_id = aws_api_gateway_rest_api.sms-api.root_resource_id
path_part = "sms"
}
resource "aws_api_gateway_method" "post_sms" {
rest_api_id = aws_api_gateway_rest_api.sms-api.id
resource_id = aws_api_gateway_resource.sms.id
http_method = "POST"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "lambda_post_sms" {
rest_api_id = aws_api_gateway_rest_api.sms-api.id
resource_id = aws_api_gateway_resource.sms.id
http_method = aws_api_gateway_method.post_sms.http_method
type = "AWS_PROXY"
integration_http_method = "POST"
uri = "arn:aws:apigateway:${data.aws_region.current.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.lambda.arn}/invocations"
}
resource "aws_api_gateway_deployment" "sms-api-deployment" {
depends_on = [
aws_api_gateway_integration.lambda_post_sms
]
rest_api_id = aws_api_gateway_rest_api.sms-api.id
}
resource "aws_api_gateway_stage" "sms-api-gateway-stage" {
deployment_id = aws_api_gateway_deployment.sms-api-deployment.id
rest_api_id = aws_api_gateway_rest_api.sms-api.id
stage_name = "prod"
description = "Production stage"
}