-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
49 lines (39 loc) · 1.12 KB
/
main.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
49
terraform {
backend "s3" {}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
resource "random_pet" "this" {
length = 2
}
module "alexa_home_assistant" {
source = "terraform-aws-modules/lambda/aws"
version = "7.7.1"
publish = true
function_name = "${random_pet.this.id}-home-assistant-alexa-skill"
handler = "index.lambda_handler"
runtime = "python3.12"
source_path = [
"${path.module}/src/index.py"
]
policy = data.aws_iam_policy.basic_execution_policy.arn
environment_variables = {
BASE_URL = var.home_assistant_base_url
DEBUG = "True"
LONG_LIVED_ACCESS_TOKEN = var.long_lived_access_token
}
}
data "aws_iam_policy" "basic_execution_policy" {
name = "AWSLambdaBasicExecutionRole"
}
resource "aws_lambda_permission" "alexa" {
statement_id = "AllowExecutionFromAlexa"
action = "lambda:InvokeFunction"
function_name = module.alexa_home_assistant.lambda_function_name
principal = "alexa-connectedhome.amazon.com"
event_source_token = var.alexa_skill_id
}