forked from cloudquery/cloudquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.tf
More file actions
59 lines (50 loc) · 1.56 KB
/
function.tf
File metadata and controls
59 lines (50 loc) · 1.56 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
49
50
51
52
53
54
55
56
57
58
59
resource "aws_iam_role" "iam_for_cloudquery" {
name = "cloudquery_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow"
}
]
}
EOF
}
data "archive_file" "zip" {
type = "zip"
source_dir = "../../../bin"
output_path = "cloudquery.zip"
}
resource "aws_iam_role_policy_attachment" "cloudquery_role_attachment1" {
role = aws_iam_role.iam_for_cloudquery.name
policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess"
}
resource "aws_iam_role_policy_attachment" "cloudquery_role_attachment2" {
role = aws_iam_role.iam_for_cloudquery.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
}
resource "aws_lambda_function" "cloudquery" {
handler = "cloudquery"
function_name = "cloudquery"
filename = "cloudquery.zip"
runtime = "go1.x"
role = aws_iam_role.iam_for_cloudquery.arn
timeout = 900
memory_size = 256
source_code_hash = data.archive_file.zip.output_base64sha256
vpc_config {
subnet_ids = [aws_subnet.rds_subnet_a.id, aws_subnet.rds_subnet_b.id]
security_group_ids = [aws_security_group.allow_mysql.id, aws_security_group.allow_egress.id]
}
environment {
variables = {
CQ_DRIVER= "mysql",
CQ_DSN = "${aws_rds_cluster.cloudquery.master_username}:${aws_rds_cluster.cloudquery.master_password}@tcp(${aws_rds_cluster.cloudquery.endpoint}:3306)/cloudquery"
}
}
}