-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
77 lines (63 loc) · 1.84 KB
/
Copy pathmain.tf
File metadata and controls
77 lines (63 loc) · 1.84 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
resource "time_offset" "expiry" {
offset_days = var.expiry_days
}
resource "aws_cloudformation_stack" "management" {
count = local.deploy_to_management ? 1 : 0
name = "AppviaAuditRole"
template_body = local.template_body
on_failure = "ROLLBACK"
capabilities = [
"CAPABILITY_NAMED_IAM",
"CAPABILITY_AUTO_EXPAND",
"CAPABILITY_IAM",
]
parameters = {
AppviaRoleARN = var.appvia_role_arn
ExternalID = var.external_id
ExpiryDate = time_offset.expiry.rfc3339
ManagedPolicyArns = join(",", var.managed_policy_arns)
}
lifecycle {
ignore_changes = [
capabilities,
]
}
}
resource "aws_cloudformation_stack_set" "member_accounts" {
name = "AppviaAuditRole"
description = "Provisions federated IAM role allowing Appvia remote audit access"
template_body = local.template_body
permission_model = "SERVICE_MANAGED"
capabilities = [
"CAPABILITY_NAMED_IAM",
"CAPABILITY_AUTO_EXPAND",
"CAPABILITY_IAM",
]
parameters = {
AppviaRoleARN = var.appvia_role_arn
ExternalID = var.external_id
ExpiryDate = time_offset.expiry.rfc3339
ManagedPolicyArns = join(",", var.managed_policy_arns)
}
auto_deployment {
enabled = true
retain_stacks_on_account_removal = false
}
lifecycle {
ignore_changes = [
administration_role_arn,
capabilities,
]
}
}
resource "aws_cloudformation_stack_set_instance" "member_accounts" {
count = length(var.deployment_account_ids) > 0 ? 1 : 0
stack_set_name = aws_cloudformation_stack_set.member_accounts.name
deployment_targets {
account_filter_type = "INTERSECTION"
accounts = local.member_account_ids
organizational_unit_ids = [
data.aws_organizations_organization.current.roots[0].id,
]
}
}