-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda_secrets.tf
45 lines (41 loc) · 1.22 KB
/
lambda_secrets.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
### Core password - needs to be set manually
resource "aws_secretsmanager_secret" "technical-account" {
name = "aws/directory-services/${aws_directory_service_directory.simpleds.id}/seamless-domain-join"
recovery_window_in_days = 30
}
resource "aws_secretsmanager_secret_version" "example" {
secret_id = aws_secretsmanager_secret.technical-account.id
secret_string = <<EOL
{
"awsSeamlessDomainUsername": "Administrator",
"awsSeamlessDomainPassword": "${var.directory_password}"
}
EOL
}
// Policy allowing read of the password
resource "aws_iam_policy" "secret" {
name = "${var.short_name}GetDsPassword"
path = "/"
description = "Policy allowing read credentials for directory service"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret"
],
"Resource": [
"${aws_secretsmanager_secret.technical-account.arn}"
]
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "secret" {
role = "${aws_iam_role.lambda_joiner.name}"
policy_arn = "${aws_iam_policy.secret.arn}"
}