Skip to content
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

feat: add OONI Dev User for GH actions #17

Merged
merged 27 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
518abfb
feat: add ooni_dev_user
DecFox Mar 13, 2024
1074c23
fix: resolve merge conflicts
DecFox Mar 13, 2024
7a4c6ac
fix: rename resources
DecFox Mar 13, 2024
46c30d0
fix: rename module resources
DecFox Mar 13, 2024
b3f27fa
Merge branch 'dev-role' into ooni-dev-user
DecFox Mar 13, 2024
a5dc3d7
fix: authorized accounts
DecFox Mar 13, 2024
d5019d5
refactor: delete old module
DecFox Mar 13, 2024
f47d32e
refactor: changes from code review
DecFox Mar 13, 2024
8f70115
fix: secretsmanager resource name
DecFox Mar 13, 2024
e1a39e9
Fix variables and run tf format
hellais Mar 13, 2024
e87aa45
Run terraform format
hellais Mar 13, 2024
4bf556b
Fix outputname
hellais Mar 13, 2024
d4c1350
Move policy to an attachement and to file
hellais Mar 13, 2024
7d4117e
Syntax fixing of policy json
hellais Mar 13, 2024
1a5a3ab
hotfix
hellais Mar 13, 2024
92a43b0
Simplify the policy
hellais Mar 13, 2024
6262f33
Fix CI
hellais Mar 13, 2024
bbceba4
Separate ansible workflow from terraform check
hellais Mar 13, 2024
a0a68b1
Fix broken terraform
hellais Mar 13, 2024
cfbb680
Set AWS credentials
hellais Mar 13, 2024
5b83905
Fix name of JSON
hellais Mar 13, 2024
9b4222a
Revert to previous policy
hellais Mar 13, 2024
a30c79c
Add missing permissions
hellais Mar 13, 2024
b38a4c0
Fix reference to inventory
hellais Mar 13, 2024
eaae382
Remove assume role from state backend
hellais Mar 13, 2024
eaf7a7e
Bump up the instance count
hellais Mar 13, 2024
d25b886
Increase the size of the ECS cluster host
hellais Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tf/environments/dev/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion tf/environments/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ locals {
## AWS Setup

provider "aws" {
profile = "oonidevops_user"
hellais marked this conversation as resolved.
Show resolved Hide resolved
region = var.aws_region
assume_role {
role_arn = "arn:aws:iam::905418398257:role/oonidevops"
Expand Down Expand Up @@ -296,3 +295,9 @@ module "ooniapi_frontend" {
)
}

module "oonidevops_github_user" {
source = "../../modules/oonidevops_github_user"

tags = local.tags
}

189 changes: 189 additions & 0 deletions tf/modules/oonidevops_github_user/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
resource "aws_iam_user" "oonidevops_github_user" {
name = "oonidevops-github"
path = "/"

tags = var.tags
}

data "aws_iam_policy_document" "oonidevops_github" {
statement {
effect = "Allow"
actions = [
"acm:Describe*",
"acm:Get*",
"acm:List*",
"application-autoscaling:Describe*",
"application-autoscaling:ListTagsForResource",
"appmesh:Describe*",
"appmesh:List*",
"autoscaling:Describe*",
"autoscaling:GetPredictiveScalingForecast",
"cloudformation:Describe*",
"cloudformation:Detect*",
"cloudformation:Estimate*",
"cloudformation:Get*",
"cloudformation:List*",
"cloudformation:ValidateTemplate",
"cloudtrail:Describe*",
"cloudtrail:Get*",
"cloudtrail:List*",
"cloudtrail:LookupEvents",
"cloudwatch:Describe*",
"cloudwatch:GenerateQuery",
"cloudwatch:Get*",
"cloudwatch:List*",
"codebuild:BatchGet*",
"codebuild:DescribeCodeCoverages",
"codebuild:DescribeTestCases",
"codebuild:List*",
"codedeploy:BatchGet*",
"codedeploy:Get*",
"codedeploy:List*",
"codepipeline:Get*",
"codepipeline:List*",
"codestar-connections:GetConnection",
"codestar-connections:GetHost",
"codestar-connections:GetRepositoryLink",
"codestar-connections:GetRepositorySyncStatus",
"codestar-connections:GetResourceSyncStatus",
"codestar-connections:GetSyncConfiguration",
"codestar-connections:ListConnections",
"codestar-connections:ListHosts",
"codestar-connections:ListRepositoryLinks",
"codestar-connections:ListRepositorySyncDefinitions",
"codestar-connections:ListSyncConfigurations",
"codestar-connections:ListTagsForResource",
"codestar-notifications:describeNotificationRule",
"codestar-notifications:listEventTypes",
"codestar-notifications:listNotificationRules",
"codestar-notifications:listTagsForResource",
"codestar-notifications:ListTargets",
"dynamodb:BatchGet*",
"dynamodb:Describe*",
"dynamodb:Get*",
"dynamodb:List*",
"dynamodb:PartiQLSelect",
"dynamodb:Query",
"dynamodb:Scan",
"ec2:Describe*",
"ec2:Get*",
"ec2:ListImagesInRecycleBin",
"ec2:ListSnapshotsInRecycleBin",
"ec2:SearchLocalGatewayRoutes",
"ec2:SearchTransitGatewayRoutes",
"ec2messages:Get*",
"ecr-public:BatchCheckLayerAvailability",
"ecr-public:DescribeImages",
"ecr-public:DescribeImageTags",
"ecr-public:DescribeRegistries",
"ecr-public:DescribeRepositories",
"ecr-public:GetAuthorizationToken",
"ecr-public:GetRegistryCatalogData",
"ecr-public:GetRepositoryCatalogData",
"ecr-public:GetRepositoryPolicy",
"ecr-public:ListTagsForResource",
"ecr:BatchCheck*",
"ecr:BatchGet*",
"ecr:Describe*",
"ecr:Get*",
"ecr:List*",
"ecs:Describe*",
"ecs:List*",
"elasticloadbalancing:Describe*",
"logs:Describe*",
"logs:FilterLogEvents",
"logs:Get*",
"logs:ListAnomalies",
"logs:ListLogAnomalyDetectors",
"logs:ListLogDeliveries",
"logs:ListTagsForResource",
"logs:ListTagsLogGroup",
"logs:StartLiveTail",
"logs:StartQuery",
"logs:StopLiveTail",
"logs:StopQuery",
"logs:TestMetricFilter",
"iam:Generate*",
"iam:Get*",
"iam:List*",
"iam:Simulate*",
"rds:Describe*",
"rds:Download*",
"rds:List*",
"route53-recovery-cluster:Get*",
"route53-recovery-cluster:ListRoutingControls",
"route53-recovery-control-config:Describe*",
"route53-recovery-control-config:GetResourcePolicy",
"route53-recovery-control-config:List*",
"route53-recovery-readiness:Get*",
"route53-recovery-readiness:List*",
"route53:Get*",
"route53:List*",
"route53:Test*",
"route53domains:Check*",
"route53domains:Get*",
"route53domains:List*",
"route53domains:View*",
"route53resolver:Get*",
"route53resolver:List*",
"s3:DescribeJob",
"s3:Get*",
"s3:List*",
"secretsmanager:Describe*",
"secretsmanager:GetResourcePolicy",
"secretsmanager:List*",
"servicediscovery:DiscoverInstances",
"servicediscovery:DiscoverInstancesRevision",
"servicediscovery:Get*",
"servicediscovery:List*",
"ssm:Describe*",
"ssm:Get*",
"ssm:List*",
"states:Describe*",
"states:GetExecutionHistory",
"states:List*",
"vpc-lattice:GetAccessLogSubscription",
"vpc-lattice:GetAuthPolicy",
"vpc-lattice:GetListener",
"vpc-lattice:GetResourcePolicy",
"vpc-lattice:GetRule",
"vpc-lattice:GetService",
"vpc-lattice:GetServiceNetwork",
"vpc-lattice:GetServiceNetworkServiceAssociation",
"vpc-lattice:GetServiceNetworkVpcAssociation",
"vpc-lattice:GetTargetGroup",
"vpc-lattice:ListAccessLogSubscriptions",
"vpc-lattice:ListListeners",
"vpc-lattice:ListRules",
"vpc-lattice:ListServiceNetworks",
"vpc-lattice:ListServiceNetworkServiceAssociations",
"vpc-lattice:ListServiceNetworkVpcAssociations",
"vpc-lattice:ListServices",
"vpc-lattice:ListTagsForResource",
"vpc-lattice:ListTargetGroups",
"vpc-lattice:ListTargets"
]
resources = ["*"]
}
}

resource "aws_iam_user_policy" "oonidevops_github" {
name = "OONIDevopsGithubPolicy"
user = aws_iam_user.oonidevops_github_user.name
policy = data.aws_iam_policy_document.oonidevops_github.json
}

resource "aws_iam_access_key" "oonidevops_github_user" {
user = aws_iam_user.oonidevops_github_user.name
}

resource "aws_secretsmanager_secret" "oonidevops_github_user_secrets" {
name = "oonidevops/github_user/access_key_json"

tags = var.tags
}

resource "aws_secretsmanager_secret_version" "oonidevops_github_user_secrets" {
hellais marked this conversation as resolved.
Show resolved Hide resolved
secret_id = aws_secretsmanager_secret.oonidevops_github_user_secrets.id
secret_string = jsonencode({"AccessKey": aws_iam_access_key.oonidevops_github_user.id, "SecretAccessKey" = aws_iam_access_key.oonidevops_github_user.secret})
}
7 changes: 7 additions & 0 deletions tf/modules/oonidevops_github_user/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "oonidevops_github_user_arn" {
hellais marked this conversation as resolved.
Show resolved Hide resolved
value = aws_iam_user.oonidevops_github_user.arn
}

output "oonidevops_github_user_secrets_id" {
value = aws_secretsmanager_secret.oonidevops_github_user_secrets.id
}
5 changes: 5 additions & 0 deletions tf/modules/oonidevops_github_user/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "tags" {
description = "tags to apply to the resources"
default = {}
type = map(string)
}
Loading