-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cloudforms policies into iam-general-policies
- Loading branch information
Showing
7 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| locals { | ||
| _module_version = "2.3.0" | ||
| _module_version = "2.4.0" | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| data "aws_iam_policy_document" "cloudforms" { | ||
| # from AmazonEC2FullAccess | ||
| statement { | ||
| sid = "AmazonEC2FullAccess" | ||
| effect = "Allow" | ||
| actions = ["ec2:*", "elasticloadbalancing:*", "cloudwatch:*", "autoscaling:*"] | ||
| resources = ["*"] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "AmazonEC2FullAccessService" | ||
| effect = "Allow" | ||
| actions = ["iam:CreateServiceLinkedRole"] | ||
| resources = ["*"] | ||
|
|
||
| condition { | ||
| test = "StringEquals" | ||
| variable = "iam:AWSServiceName" | ||
|
|
||
| values = [ | ||
| "autoscaling.amazonaws.com", | ||
| "ec2scheduled.amazonaws.com", | ||
| "elasticloadbalancing.amazonaws.com", | ||
| "spot.amazonaws.com", | ||
| "spotfleet.amazonaws.com", | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| # from AWSConfigUserAccess | ||
| statement { | ||
| sid = "AWSConfigUserAccess" | ||
| effect = "Allow" | ||
| resources = ["*"] | ||
|
|
||
| actions = [ | ||
| "config:Get*", | ||
| "config:Describe*", | ||
| "config:Deliver*", | ||
| "config:List*", | ||
| "tag:GetResources", | ||
| "tag:GetTagKeys", | ||
| "cloudtrail:DescribeTrails", | ||
| "cloudtrail:GetTrailStatus", | ||
| "cloudtrail:LookupEvents", | ||
| "sns:List*", | ||
| "sqs:List*", | ||
| ] | ||
| } | ||
|
|
||
| # from IAMReadOnlyAccess | ||
| statement { | ||
| sid = "IAMReadOnlyAccess" | ||
| effect = "Allow" | ||
| resources = ["*"] | ||
|
|
||
| actions = [ | ||
| "iam:GenerateCredentialReport", | ||
| "iam:GenerateServiceLastAccessedDetails", | ||
| "iam:Get*", | ||
| "iam:List*", | ||
| "iam:SimulateCustomPolicy", | ||
| "iam:SimulatePrincipalPolicy", | ||
| ] | ||
| } | ||
|
|
||
| # from IAMUserSSHKeys | ||
| statement { | ||
| sid = "IAMUserSSHKeys" | ||
| effect = "Allow" | ||
| resources = ["arn:${data.aws_arn.current.partition}:iam::*:user/$${aws:username}"] | ||
|
|
||
| actions = [ | ||
| "iam:DeleteSSHPublicKey", | ||
| "iam:GetSSHPublicKey", | ||
| "iam:ListSSHPublicKeys", | ||
| "iam:UpdateSSHPublicKey", | ||
| "iam:UploadSSHPublicKey", | ||
| ] | ||
| } | ||
|
|
||
| # from AWSCloudFormationReadOnlyAccess | ||
| statement { | ||
| sid = "AWSCloudFormationReadOnlyAccess" | ||
| effect = "Allow" | ||
| resources = ["*"] | ||
|
|
||
| actions = [ | ||
| "cloudformation:Describe*", | ||
| "cloudformation:EstimateTemplateCost", | ||
| "cloudformation:Get*", | ||
| "cloudformation:List*", | ||
| "cloudformation:ValidateTemplate", | ||
| ] | ||
| } | ||
|
|
||
| # for SQS | ||
| statement { | ||
| sid = "AWSManageCloudformsSQS" | ||
| effect = "Allow" | ||
| resources = [for r in values(var.region_map) : format("arn:%v:sqs:%v:%v:manageiq-awsconfig-queue-*", data.aws_arn.current.partition, r, var.account_id)] | ||
| actions = ["sqs:*"] | ||
| } | ||
|
|
||
| # for SNS | ||
| statement { | ||
| sid = "AWSCloudformsSNS" | ||
| effect = "Allow" | ||
| resources = [for r in values(var.region_map) : format("arn:%v:sns:%v:%v:AWSConfig_topic", data.aws_arn.current.partition, r, var.account_id)] | ||
| actions = ["sns:*"] | ||
| } | ||
|
|
||
| # from KMS read access to get the default kms key id for EBS | ||
| statement { | ||
| sid = "KMSReadOnlyAccess" | ||
| effect = "Allow" | ||
| resources = ["*"] | ||
|
|
||
| actions = [ | ||
| "kms:ListKeys", | ||
| "kms:ListKeyPolicies", | ||
| "kms:ListAliases", | ||
| "kms:DescribeKey" | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| #--- | ||
| # setup policy for cloudforms to access kms in remote ami | ||
| # this applies only to gov accounts at this time | ||
| #--- | ||
| # "AliasName": "alias/k-kms-csvd-img-shared-key", | ||
| # these are not pulled with data as they require a diff account/profile to do so | ||
| # move this out into some settings file | ||
| locals { | ||
| cloudforms_ami_kms_keys = { | ||
| "aws" = [] | ||
| "aws-us-gov" = [ | ||
| "arn:aws-us-gov:kms:us-gov-west-1:107742151971:key/6b0f5037-a500-41f8-b13b-c57f0de9332f", | ||
| "arn:aws-us-gov:kms:us-gov-east-1:107742151971:key/7928e94e-b28e-4863-99aa-ef0ce193c634" | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "cloudforms_ami" { | ||
| # for access to remote AMI key | ||
| dynamic "statement" { | ||
| for_each = length(local.cloudforms_ami_kms_keys[data.aws_arn.current.partition]) > 0 ? { data.aws_arn.current.partition = local.cloudforms_ami_kms_keys[data.aws_arn.current.partition] } : {} | ||
| iterator = c | ||
| content { | ||
| sid = "AWSCloudformsAMIKeyAccess" | ||
| effect = "Allow" | ||
| resources = c.value | ||
| actions = [ | ||
| "kms:DescribeKey", | ||
| "kms:ReEncrypt*", | ||
| "kms:CreateGrant", | ||
| "kms:Decrypt", | ||
| ] | ||
| } | ||
| } | ||
| } |