-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcommon.tf
66 lines (55 loc) · 1.91 KB
/
common.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Copyright (C) 2018-2019 Expedia Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
locals {
instance_alias = var.instance_name == "" ? "waggledance" : format("waggledance-%s", var.instance_name)
remote_metastore_zone_prefix = var.instance_name == "" ? "remote-metastore" : format("remote-metastore-%s", var.instance_name)
}
data "aws_caller_identity" "current" {}
data "aws_vpc" "waggledance_vpc" {
id = var.vpc_id
}
data "aws_secretsmanager_secret" "bastion_ssh_key" {
count = var.bastion_ssh_key_secret_name == "" ? 0 : 1
name = var.bastion_ssh_key_secret_name
}
data "aws_secretsmanager_secret" "docker_registry" {
count = var.docker_registry_auth_secret_name == "" ? 0 : 1
name = var.docker_registry_auth_secret_name
}
data "aws_iam_policy_document" "waggle_dance_glue_policy" {
count = length(var.glue_metastores) > 0 ? 1 : 0
statement {
sid = "WaggledanceGluePolicy"
actions = [
"glue:GetDatabase",
"glue:GetDatabases",
"glue:GetTable",
"glue:GetTables",
"glue:GetTableVersions",
"glue:GetPartition",
"glue:GetPartitions",
"glue:BatchGetPartition",
"glue:GetUserDefinedFunction",
"glue:GetUserDefinedFunctions"
]
resources = [
for glue_metastore in var.glue_metastores:
format("arn:aws:glue:%s:%s:*", var.aws_region, glue_metastore["glue-account-id"])
]
}
}
data "aws_secretsmanager_secret" "datadog_key" {
count = length(var.datadog_key_secret_name) > 0 ? 1 : 0
name = var.datadog_key_secret_name
}
data "aws_secretsmanager_secret_version" "datadog_key" {
count = length(var.datadog_key_secret_name) > 0 ? 1 : 0
secret_id = data.aws_secretsmanager_secret.datadog_key[0].id
}
data "external" "datadog_key" {
count = length(var.datadog_key_secret_name) > 0 ? 1 : 0
program = ["echo", "${data.aws_secretsmanager_secret_version.datadog_key[0].secret_string}"]
}