Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ module "github_runner" {
| <a name="input_s3_logs_bucket_prefix"></a> [s3\_logs\_bucket\_prefix](#input\_s3\_logs\_bucket\_prefix) | Prefix to use for the logs in the S3 bucket | `string` | `""` | no |
| <a name="input_security_group_ids"></a> [security\_group\_ids](#input\_security\_group\_ids) | The list of Security Group IDs for AWS CodeBuild to launch ephemeral EC2 instances in. | `list(string)` | `[]` | no |
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | Name to use on created Security Group. Defaults to `name` | `string` | `null` | no |
| <a name="input_source_location"></a> [source\_location](#input\_source\_location) | Your source code repo location, for example https://github.com/my/repo.git | `string` | n/a | yes |
| <a name="input_source_location"></a> [source\_location](#input\_source\_location) | Your source code repo location, for example https://github.com/my/repo.git, or `CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION` for org-level webhooks | `string` | n/a | yes |
| <a name="input_source_organization"></a> [source\_organization](#input\_source\_organization) | Your Github organization name for organization-level webhook creation | `string` | `null` | no |
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | The list of Subnet IDs for AWS CodeBuild to launch ephemeral EC2 instances in. | `list(string)` | `[]` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID for AWS CodeBuild to launch ephemeral instances in. | `string` | `null` | no |

Expand Down
12 changes: 12 additions & 0 deletions docs/org_level_runners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Organization Level Runners

To set up the codebuild runners at the GitHub organization level, use the `source_location` and `source_organization` module inputs like the following:

```hcl
module "github_runner" {
...
source_location = "CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION"
source_organization = "your-org-name"
...
}
```
69 changes: 69 additions & 0 deletions examples/basic-org/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!-- BEGIN_TF_DOCS -->
----
## main.tf
```hcl
module "github_runner" {
source = "../../"

# Required parameters
############################
# Naming for all created resources
name = "github-runner-codebuild-test"
source_location = "CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION"
source_organization = "cloudandthings"

# Environment image is not specified so it will default to:
# "aws/codebuild/amazonlinux2-x86_64-standard:5.0"

# Optional parameters
############################
description = "Created by my-org/my-runner-repo.git"

github_personal_access_token = "example"

vpc_id = "vpc-0ffaabbcc1122"
subnet_ids = ["subnet-0123", "subnet-0456"]
}
```
----

## Documentation

----
### Inputs

No inputs.

----
### Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_github_runner"></a> [github\_runner](#module\_github\_runner) | ../../ | n/a |

----
### Outputs

No outputs.

----
### Providers

No providers.

----
### Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9 |
| <a name="requirement_http"></a> [http](#requirement\_http) | 3.0.1 |

----
### Resources

No resources.

----
<!-- END_TF_DOCS -->
22 changes: 22 additions & 0 deletions examples/basic-org/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module "github_runner" {
source = "../../"

# Required parameters
############################
# Naming for all created resources
name = "github-runner-codebuild-test"
source_location = "CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION"
source_organization = "cloudandthings"

# Environment image is not specified so it will default to:
# "aws/codebuild/amazonlinux2-x86_64-standard:5.0"

# Optional parameters
############################
description = "Created by my-org/my-runner-repo.git"

github_personal_access_token = "example"

vpc_id = "vpc-0ffaabbcc1122"
subnet_ids = ["subnet-0123", "subnet-0456"]
}
Empty file added examples/basic-org/outputs.tf
Empty file.
3 changes: 3 additions & 0 deletions examples/basic-org/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = "eu-west-1"
}
13 changes: 13 additions & 0 deletions examples/basic-org/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_version = ">= 0.14.0"
required_providers {
http = {
source = "hashicorp/http"
version = "3.0.1"
}
aws = {
source = "hashicorp/aws"
version = ">= 4.9"
}
}
}
Empty file.
7 changes: 7 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ resource "aws_codebuild_webhook" "this" {
pattern = "WORKFLOW_JOB_QUEUED"
}
}
dynamic "scope_configuration" {
for_each = var.source_location == "CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION" ? toset([1]) : toset([])
content {
name = var.source_organization
scope = "GITHUB_ORGANIZATION"
}
}
}

################################################################################
Expand Down
8 changes: 7 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ variable "name" {

variable "source_location" {
type = string
description = "Your source code repo location, for example https://github.com/my/repo.git"
description = "Your source code repo location, for example https://github.com/my/repo.git, or `CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION` for org-level webhooks"
}

# -----------------------------------------------------
# Optional variables
# -----------------------------------------------------

# General
variable "source_organization" {
type = string
default = null
description = "Your Github organization name for organization-level webhook creation"
}

variable "build_timeout" {
type = number
default = 5
Expand Down
Loading