-
Notifications
You must be signed in to change notification settings - Fork 19
feat: manage pypi aws tf groups, memberships, policies #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JacobCoffee
wants to merge
5
commits into
main
Choose a base branch
from
aws-tf-managed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
af0d7ea
feat: manage pypi aws tf groups and memberships
JacobCoffee 0f72bfc
fix: clean up things we dont use/are default
JacobCoffee 80bdb04
feat: codify polciies into tf
JacobCoffee 84dbb78
apply code reviiew
JacobCoffee 4711d30
fix: dont output role now that we removed it
JacobCoffee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,111 @@ | ||
# Datadog AWS Integration Resources | ||
|
||
resource "aws_iam_policy" "datadog_integration" { | ||
name = "AWSDataDogIntegration" | ||
|
||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Action = [ | ||
"autoscaling:Describe*", | ||
"budgets:ViewBudget", | ||
"cloudfront:GetDistributionConfig", | ||
"cloudfront:ListDistributions", | ||
"cloudtrail:DescribeTrails", | ||
"cloudtrail:GetTrailStatus", | ||
"cloudwatch:Describe*", | ||
"cloudwatch:Get*", | ||
"cloudwatch:List*", | ||
"codedeploy:List*", | ||
"codedeploy:BatchGet*", | ||
"directconnect:Describe*", | ||
"dynamodb:List*", | ||
"dynamodb:Describe*", | ||
"ec2:Describe*", | ||
"ec2:Get*", | ||
"ecs:Describe*", | ||
"ecs:List*", | ||
"elasticache:Describe*", | ||
"elasticache:List*", | ||
"elasticfilesystem:DescribeFileSystems", | ||
"elasticfilesystem:DescribeTags", | ||
"elasticloadbalancing:Describe*", | ||
"elasticmapreduce:List*", | ||
"elasticmapreduce:Describe*", | ||
"es:ListTags", | ||
"es:ListDomainNames", | ||
"es:DescribeElasticsearchDomains", | ||
"health:DescribeEvents", | ||
"health:DescribeEventDetails", | ||
"health:DescribeAffectedEntities", | ||
"kinesis:List*", | ||
"kinesis:Describe*", | ||
"lambda:AddPermission", | ||
"lambda:GetPolicy", | ||
"lambda:List*", | ||
"lambda:RemovePermission", | ||
"logs:Get*", | ||
"logs:Describe*", | ||
"logs:FilterLogEvents", | ||
"logs:TestMetricFilter", | ||
"rds:Describe*", | ||
"rds:List*", | ||
"redshift:DescribeClusters", | ||
"redshift:DescribeLoggingStatus", | ||
"route53:List*", | ||
"s3:GetBucketTagging", | ||
"s3:ListAllMyBuckets", | ||
"s3:GetBucketLogging", | ||
"s3:GetBucketLocation", | ||
"s3:GetBucketNotification", | ||
"s3:ListAllMyBuckets", | ||
"s3:PutBucketNotification", | ||
"ses:Get*", | ||
"sns:List*", | ||
"sns:Publish", | ||
"sqs:ListQueues", | ||
"support:*", | ||
"tag:getResources", | ||
"tag:getTagKeys", | ||
"tag:getTagValues", | ||
"apigateway:GET", | ||
"ec2:SearchTransitGatewayRoutes", | ||
"elasticfilesystem:DescribeAccessPoints", | ||
"fsx:DescribeFileSystems", | ||
"states:ListStateMachines", | ||
"apigateway:GET" | ||
] | ||
Resource = "*" | ||
} | ||
] | ||
}) | ||
} | ||
|
||
resource "aws_iam_role" "datadog_integration" { | ||
name = "AWSDataDogIntegration" | ||
|
||
assume_role_policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Principal = { | ||
AWS = "arn:aws:iam::464622532012:root" | ||
} | ||
Action = "sts:AssumeRole" | ||
Condition = { | ||
StringEquals = { | ||
"sts:ExternalId" = "63ce1985605d40499b0a2a0091d76b0e" | ||
} | ||
} | ||
} | ||
] | ||
}) | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "datadog_integration" { | ||
role = aws_iam_role.datadog_integration.name | ||
policy_arn = aws_iam_policy.datadog_integration.arn | ||
} |
This file contains hidden or 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,2 @@ | ||
# Data source to get current AWS account info | ||
data "aws_caller_identity" "current" {} |
This file contains hidden or 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,13 @@ | ||
output "role_arns" { | ||
description = "ARNs of IAM roles" | ||
value = { | ||
datadog_integration = aws_iam_role.datadog_integration.arn | ||
} | ||
} | ||
|
||
output "policy_arns" { | ||
description = "ARNs of custom IAM policies" | ||
value = { | ||
datadog_integration = aws_iam_policy.datadog_integration.arn | ||
} | ||
} |
This file contains hidden or 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,154 @@ | ||
# PyPI IAM Policies | ||
|
||
# to clean up (?) | ||
# pypi-bandersnatch-mirror - 1031 days ago | ||
# pypi-db-backup-archive - 795 days ago | ||
# PyPIReadOnly - 913 days ago | ||
|
||
# opensearch | ||
resource "aws_iam_policy" "pypi_elasticsearch" { | ||
name = "PyPIElasticSearch" | ||
|
||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Sid = "VisualEditor0" | ||
Effect = "Allow" | ||
Action = [ | ||
"es:DescribeReservedElasticsearchInstanceOfferings", | ||
"es:ESHttpGet", | ||
"es:ListTags", | ||
"es:DescribeElasticsearchDomainConfig", | ||
"es:GetUpgradeHistory", | ||
"es:DescribeReservedElasticsearchInstances", | ||
"es:ESHttpHead", | ||
"es:ListDomainNames", | ||
"es:DescribeElasticsearchDomain", | ||
"es:GetCompatibleElasticsearchVersions", | ||
"es:GetUpgradeStatus", | ||
"es:DescribeElasticsearchDomains", | ||
"es:ListElasticsearchInstanceTypes", | ||
"es:ListElasticsearchVersions", | ||
"es:DescribeElasticsearchInstanceTypeLimits" | ||
] | ||
Resource = "*" | ||
}, | ||
{ | ||
Sid = "VisualEditor1" | ||
Effect = "Allow" | ||
Action = "es:*" | ||
Resource = "arn:aws:es:us-east-2:220435833635:domain/warehouse-7/production*" | ||
}, | ||
{ | ||
Sid = "VisualEditor2" | ||
Effect = "Allow" | ||
Action = "es:*" | ||
Resource = "arn:aws:es:us-east-2:220435833635:domain/warehouse-opensearch/production*" | ||
} | ||
] | ||
}) | ||
} | ||
|
||
# amazon ses | ||
resource "aws_iam_policy" "pypi_email" { | ||
name = "PyPIEmail" | ||
description = "Allows sending email as pypi.org" | ||
|
||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Action = [ | ||
"ses:SendEmail", | ||
"ses:SendRawEmail" | ||
] | ||
Resource = "arn:aws:ses:us-west-2:220435833635:identity/pypi.org" | ||
}, | ||
{ | ||
Effect = "Allow" | ||
Action = [ | ||
"sns:ConfirmSubscription" | ||
] | ||
Resource = "arn:aws:sns:us-west-2:220435833635:pypi-ses-delivery-events-topic" | ||
} | ||
] | ||
}) | ||
} | ||
|
||
# pypi files/docs ro - unused 913 days | ||
JacobCoffee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# resource "aws_iam_policy" "pypi_readonly" { | ||
# name = "PyPIReadOnly" | ||
# description = "PyPI Files/Docs Read-Only Access" | ||
# | ||
# policy = jsonencode({ | ||
# Version = "2012-10-17" | ||
# Statement = [ | ||
# { | ||
# Effect = "Allow" | ||
# Action = [ | ||
# "s3:GetObject", | ||
# "s3:ListBucket" | ||
# ] | ||
# Resource = [ | ||
# "arn:aws:s3:::pypi-docs", | ||
# "arn:aws:s3:::pypi-docs/*", | ||
# "arn:aws:s3:::pypi-files", | ||
# "arn:aws:s3:::pypi-files/*" | ||
# ] | ||
# } | ||
# ] | ||
# }) | ||
# } | ||
|
||
# s3 r/w | ||
resource "aws_iam_policy" "pypi_s3_access" { | ||
name = "PyPIS3Access" | ||
description = "R/W Access to the PyPI S3 Buckets" | ||
|
||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Action = "s3:ListAllMyBuckets" | ||
Resource = "*" | ||
}, | ||
{ | ||
Effect = "Allow" | ||
Action = "s3:*" | ||
Resource = [ | ||
"arn:aws:s3:::pypi-docs", | ||
"arn:aws:s3:::pypi-docs/*" | ||
] | ||
}, | ||
{ | ||
Effect = "Allow" | ||
Action = "s3:*" | ||
Resource = [ | ||
"arn:aws:s3:::pypi-files", | ||
"arn:aws:s3:::pypi-files/*", | ||
"arn:aws:s3:::pypi-files-archive", | ||
"arn:aws:s3:::pypi-files-archive/*" | ||
] | ||
}, | ||
{ | ||
Effect = "Deny" | ||
Action = [ | ||
"s3:DeleteBucket", | ||
"s3:DeleteBucketPolicy", | ||
"s3:DeleteBucketWebsite", | ||
"s3:DeleteObject", | ||
"s3:DeleteObjectVersion" | ||
] | ||
Resource = [ | ||
"arn:aws:s3:::pypi-files", | ||
"arn:aws:s3:::pypi-files/*", | ||
"arn:aws:s3:::pypi-files-archive", | ||
"arn:aws:s3:::pypi-files-archive/*" | ||
] | ||
} | ||
] | ||
}) | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.