Skip to content

Commit 382d35b

Browse files
authored
Add support for permissions boundaries (#26)
* Add support for permissions boundaries * Add support for permissions boundaries
1 parent 4a6b8a2 commit 382d35b

32 files changed

+564
-64
lines changed

examples/default/vpc.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module "vpc" {
22
source = "git::https://github.com/philips-software/terraform-aws-vpc.git?ref=2.1.0"
33

4-
environment = local.environment
5-
aws_region = local.aws_region
4+
environment = local.environment
5+
aws_region = local.aws_region
6+
create_private_hosted_zone = false
67
}
78

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Runners deployed with permissions boundary
2+
3+
This modules shows how to create GitHub action runners with permissions boundaries and paths used in role, policies, and instance profiles.
4+
5+
## Usages
6+
7+
Steps for the full setup, such as creating a GitHub app can be find the module [README](../../README.md). First create the deploy role and boundary policies. This steps required an admin user.
8+
9+
```bash
10+
cd setup
11+
terraform init
12+
terraform apply
13+
cd ..
14+
```
15+
16+
After the apply a new role and policies are created, the state of the first step is imported in this workspace to load the role and policy. The deployment of the runner module is first assuming the new role before creating all resources. Before running Terraform, ensure the GitHub app is configured.
17+
18+
```
19+
terraform init
20+
terraform apply
21+
```
22+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module "lambdas" {
2+
source = "../../../modules/download-lambda"
3+
lambdas = [
4+
{
5+
name = "webhook"
6+
tag = "v0.0.0-beta"
7+
},
8+
{
9+
name = "runners"
10+
tag = "v0.0.0-beta"
11+
},
12+
{
13+
name = "runner-binaries-syncer"
14+
tag = "v0.0.0-beta"
15+
}
16+
]
17+
}
18+
19+
output "files" {
20+
value = module.lambdas.files
21+
}

examples/permissions-boundary/main.tf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
locals {
2+
environment = "boundaries"
3+
aws_region = "eu-west-1"
4+
}
5+
6+
resource "random_password" "random" {
7+
length = 32
8+
}
9+
10+
data "terraform_remote_state" "iam" {
11+
backend = "local"
12+
13+
config = {
14+
path = "${path.module}/setup/terraform.tfstate"
15+
}
16+
}
17+
18+
module "runners" {
19+
source = "../../"
20+
providers = {
21+
aws = aws.terraform_role
22+
}
23+
24+
aws_region = local.aws_region
25+
vpc_id = module.vpc.vpc_id
26+
subnet_ids = module.vpc.private_subnets
27+
28+
environment = local.environment
29+
tags = {
30+
Project = "ProjectX"
31+
}
32+
33+
github_app = {
34+
key_base64 = var.github_app_key_base64
35+
id = var.github_app_id
36+
client_id = var.github_app_client_id
37+
client_secret = var.github_app_client_secret
38+
webhook_secret = random_password.random.result
39+
}
40+
41+
webhook_lambda_zip = "lambdas-download/webhook.zip"
42+
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
43+
runners_lambda_zip = "lambdas-download/runners.zip"
44+
enable_organization_runners = false
45+
runner_extra_labels = "default,example"
46+
47+
instance_profile_path = "/runners/"
48+
role_path = "/runners/"
49+
role_permissions_boundary = data.terraform_remote_state.iam.outputs.boundary
50+
}
51+
52+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
output "runners" {
2+
value = {
3+
lambda_syncer_name = module.runners.binaries_syncer.lambda.function_name
4+
}
5+
}
6+
7+
output "webhook" {
8+
value = {
9+
secret = random_password.random.result
10+
endpoint = module.runners.webhook.endpoint
11+
}
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
provider "aws" {
2+
alias = "terraform_role"
3+
region = local.aws_region
4+
version = "2.61"
5+
assume_role {
6+
role_arn = data.terraform_remote_state.iam.outputs.role
7+
}
8+
}
9+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
data "aws_caller_identity" "current" {}
2+
3+
module "iam" {
4+
source = "../../../modules/setup-iam-permissions"
5+
6+
environment = "boundaries"
7+
account_id = data.aws_caller_identity.current.account_id
8+
9+
namespaces = {
10+
boundary_namespace = "bounaries"
11+
role_namespace = "runners"
12+
policy_namespace = "runners"
13+
instance_profile_namespace = "runners"
14+
}
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "role" {
2+
value = module.iam.role
3+
}
4+
5+
output "boundary" {
6+
value = module.iam.boundary
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "aws" {
2+
region = "eu-west-1"
3+
version = "2.61"
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
variable "github_app_key_base64" {}
3+
4+
variable "github_app_id" {}
5+
6+
variable "github_app_client_id" {}
7+
8+
variable "github_app_client_secret" {}
9+

0 commit comments

Comments
 (0)