-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapigateway.tf
More file actions
48 lines (41 loc) · 1.54 KB
/
apigateway.tf
File metadata and controls
48 lines (41 loc) · 1.54 KB
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
resource "aws_api_gateway_rest_api" "emojiBot" {
name = "emojiBot-${terraform.workspace}"
endpoint_configuration {
types = ["REGIONAL"]
}
}
// custom path for recieving emojies from slack API
resource "aws_api_gateway_resource" "slackConnector" {
path_part = "slack"
parent_id = aws_api_gateway_rest_api.emojiBot.root_resource_id
rest_api_id = aws_api_gateway_rest_api.emojiBot.id
}
resource "aws_api_gateway_method" "slackConnector" {
rest_api_id = aws_api_gateway_rest_api.emojiBot.id
resource_id = aws_api_gateway_resource.slackConnector.id
http_method = "POST"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "slackConnector" {
rest_api_id = aws_api_gateway_rest_api.emojiBot.id
resource_id = aws_api_gateway_resource.slackConnector.id
http_method = aws_api_gateway_method.slackConnector.http_method
integration_http_method = "POST"
type = "AWS_PROXY"
uri = aws_lambda_function.slackConnector.invoke_arn
}
# Deployment
resource "aws_api_gateway_deployment" "botv1" {
rest_api_id = aws_api_gateway_rest_api.emojiBot.id
stage_name = "prod"
depends_on = [
aws_api_gateway_integration.slackConnector,
]
}
# Create access to url https://emojibot.aws.ctrlok.dev/v1/slack
resource "aws_api_gateway_base_path_mapping" "botv1" {
api_id = aws_api_gateway_rest_api.emojiBot.id
domain_name = aws_api_gateway_domain_name.emojibot.domain_name
stage_name = aws_api_gateway_deployment.botv1.stage_name
base_path = "v1"
}