Skip to content

Commit 94d2602

Browse files
authored
Merge pull request #5 from appvia/custom-roles
Support for custom managed policies
2 parents 77be143 + a85cc7e commit 94d2602

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ No modules.
7777
| <a name="input_external_id"></a> [external\_id](#input\_external\_id) | External ID should be a string of cryptographically safe random characters | `string` | n/a | yes |
7878
| <a name="input_appvia_role_arn"></a> [appvia\_role\_arn](#input\_appvia\_role\_arn) | Allows specifying a non-standard IAM role. Only set this if asked to do so by Appvia | `string` | `"arn:aws:iam::730335310409:role/aws-reserved/sso.amazonaws.com/eu-west-2/AWSReservedSSO_WAFSupport_19c9bc61106389c3"` | no |
7979
| <a name="input_expiry_days"></a> [expiry\_days](#input\_expiry\_days) | The number of days the role is available before access will be denied | `number` | `14` | no |
80+
| <a name="input_managed_policy_arns"></a> [managed\_policy\_arns](#input\_managed\_policy\_arns) | List of managed AWS policy ARNs to apply to the role | `list(string)` | <pre>[<br> "arn:aws:iam::aws:policy/SecurityAudit",<br> "arn:aws:iam::aws:policy/ReadOnlyAccess"<br>]</pre> | no |
8081

8182
## Outputs
8283

cloud_formation/role.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Parameters:
55
Type: String
66
Description: Fully-qualified ARN of the remote role
77
Default: arn:aws:iam::730335310409:role/aws-reserved/sso.amazonaws.com/eu-west-2/AWSReservedSSO_WAFSupport_19c9bc61106389c3
8+
ManagedPolicyArns:
9+
Type: CommaDelimitedList
10+
Description: List of AWS managed policy ARNs to apply to the role
11+
Default: 'arn:aws:iam::aws:policy/SecurityAudit, arn:aws:iam::aws:policy/ReadOnlyAccess'
812
ExternalID:
913
Type: String
1014
Description: External ID shared between consumer and Appvia
@@ -29,9 +33,7 @@ Resources:
2933
Condition:
3034
StringEquals:
3135
"sts:ExternalId": !Ref ExternalID
32-
ManagedPolicyArns:
33-
- arn:aws:iam::aws:policy/SecurityAudit
34-
- arn:aws:iam::aws:policy/ReadOnlyAccess
36+
ManagedPolicyArns: !Ref ManagedPolicyArns
3537
Policies:
3638
- PolicyName: PermissionDeadline
3739
PolicyDocument:

main.tf

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ resource "aws_cloudformation_stack" "management" {
1616
]
1717

1818
parameters = {
19-
AppviaRoleARN = var.appvia_role_arn
20-
ExternalID = var.external_id
21-
ExpiryDate = time_offset.expiry.rfc3339
19+
AppviaRoleARN = var.appvia_role_arn
20+
ExternalID = var.external_id
21+
ExpiryDate = time_offset.expiry.rfc3339
22+
ManagedPolicyArns = join(",", var.managed_policy_arns)
2223
}
2324

2425
lifecycle {
@@ -41,9 +42,10 @@ resource "aws_cloudformation_stack_set" "member_accounts" {
4142
]
4243

4344
parameters = {
44-
AppviaRoleARN = var.appvia_role_arn
45-
ExternalID = var.external_id
46-
ExpiryDate = time_offset.expiry.rfc3339
45+
AppviaRoleARN = var.appvia_role_arn
46+
ExternalID = var.external_id
47+
ExpiryDate = time_offset.expiry.rfc3339
48+
ManagedPolicyArns = join(",", var.managed_policy_arns)
4749
}
4850

4951
auto_deployment {

variables.tf

+10
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ variable "expiry_days" {
1919
default = 14
2020
description = "The number of days the role is available before access will be denied"
2121
}
22+
23+
variable "managed_policy_arns" {
24+
type = list(string)
25+
description = "List of managed AWS policy ARNs to apply to the role"
26+
27+
default = [
28+
"arn:aws:iam::aws:policy/SecurityAudit",
29+
"arn:aws:iam::aws:policy/ReadOnlyAccess",
30+
]
31+
}

0 commit comments

Comments
 (0)