Skip to content

Commit 30a2e2c

Browse files
authored
Merge pull request #1 from cloudposse/feature/initial-implementation
2 parents c254ece + f1df56d commit 30a2e2c

File tree

13 files changed

+446
-280
lines changed

13 files changed

+446
-280
lines changed

.github/auto-release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ version-resolver:
1717
- 'bugfix'
1818
- 'bug'
1919
- 'hotfix'
20-
- 'no-release'
2120
default: 'minor'
2221

2322
categories:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Local .terraform directories
22
**/.terraform
33
**/.terraform.d
4+
**/bin/
45

56
# .tfstate files
67
*.tfstate
@@ -11,6 +12,7 @@
1112

1213
**/.idea
1314
**/*.iml
15+
.DS_Store
1416

1517
# Cloud Posse Build Harness https://github.com/cloudposse/build-harness
1618
**/.build-harness

README.md

Lines changed: 102 additions & 69 deletions
Large diffs are not rendered by default.

README.yaml

Lines changed: 58 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,11 @@
1-
########################################################################################################################
2-
########################################################################################################################
3-
########################################################################################################################
4-
# DELETE ME
5-
#
6-
# This is the README configuration for the Example module itself.
7-
# Delete this (up to and including the line with `---`) and fill in
8-
# the template below the dashes
9-
10-
# Name of this project
11-
name: terraform-example-module
12-
13-
# License of this project
14-
license: "APACHE2"
15-
16-
# Copyrights
17-
copyrights:
18-
- name: "Cloud Posse, LLC"
19-
url: "https://cloudposse.com"
20-
year: "2021"
21-
22-
# Canonical GitHub repo
23-
github_repo: cloudposse/terraform-example-module
24-
25-
description: |-
26-
This is an example project to provide all the scaffolding for a typical well-built Cloud Posse
27-
Terraform module for AWS resources. It's a template repository you can
28-
use when creating new repositories. This is not a useful module by itself.
29-
30-
quickstart: |-
31-
1. Use this repo as a template for a new repo.
32-
2. Check out the new repo and create a `git` branch to work on.
33-
3. Replace the Terraform code at the root of the repo with the code you want to publish.
34-
4. Replace the code in `examples/complete` with Terraform code that will make a good automated test.
35-
Please keep `context.tf` and `fixtures.us-east-2.tfvars` in place and change only `name`, leaving
36-
`region`, `namespace`, `environment`, and `stage` as is. Provide outputs that will be useful for testing.
37-
5. Update `test/src/examples_complete_test.go` to verify the outputs of running `terraform apply` on `examples/complete`.
38-
6. Run `make github/init` to update the repo with the current Cloud Posse framework files (e.g. `CODEOWNERS`).
39-
7. Run `make pr/auto-format` to format the Terraform code and generate documentation.
40-
8. Commit everything to `git` and open your first PR on the new repo.
41-
42-
references:
43-
- name: "Cloud Posse Documentation"
44-
url: "https://docs.cloudposse.com"
45-
description: "The Cloud Posse Developer Hub (documentation)"
46-
- name: "Terraform Standard Module Structure"
47-
description: "HashiCorp's standard module structure is a file and directory layout we recommend for reusable modules distributed in separate repositories."
48-
url: "https://www.terraform.io/docs/language/modules/develop/structure.html"
49-
- name: "Terraform Module Requirements"
50-
description: "HashiCorp's guidance on all the requirements for publishing a module. Meeting the requirements for publishing a module is extremely easy."
51-
url: "https://www.terraform.io/docs/registry/modules/publish.html#requirements"
52-
- name: "Terraform Version Pinning"
53-
description: "The required_version setting can be used to constrain which versions of the Terraform CLI can be used with your configuration"
54-
url: "https://www.terraform.io/docs/language/settings/index.html#specifying-a-required-terraform-version"
55-
56-
related:
57-
- name: "Example App"
58-
url: "https://github.com/cloudposse/example-app"
59-
description: "Example application for CI/CD demonstrations of Codefresh"
60-
61-
621
---
63-
# DELETE ME
64-
#
65-
# The above is the README configuration for the Example module itself.
66-
# Delete from here to the top of file and fill in the template below
67-
########################################################################################################################
68-
########################################################################################################################
69-
########################################################################################################################
70-
71-
722
#
733
# This is the canonical configuration for the `README.md`
744
# Run `make readme` to rebuild the `README.md`
755
#
766

777
# Name of this project
78-
name:
8+
name: terraform-aws-github-action-token-rotator
799

8010
# Logo for this project
8111
#logo: docs/logo.png
@@ -87,85 +17,92 @@ license: "APACHE2"
8717
copyrights:
8818
- name: "Cloud Posse, LLC"
8919
url: "https://cloudposse.com"
90-
year: "2021"
20+
year: "2022"
9121

9222
# Canonical GitHub repo
93-
github_repo:
23+
github_repo: cloudposse/terraform-aws-github-action-token-rotator
9424

9525
# Badges to display
9626
badges:
27+
- name: "Build Status"
28+
image: "https://github.com/cloudposse/build-harness/workflows/docker/badge.svg?branch=main"
29+
url: "https://github.com/cloudposse/build-harness/actions?query=workflow%3Adocker"
9730
- name: "Latest Release"
98-
image: "https://img.shields.io/github/release/cloudposse/terraform-example-module.svg"
99-
url: "https://github.com/cloudposse/terraform-example-module/releases/latest"
31+
image: "https://img.shields.io/github/release/cloudposse/build-harness.svg"
32+
url: "https://github.com/cloudposse/build-harness/releases/latest"
10033
- name: "Slack Community"
10134
image: "https://slack.cloudposse.com/badge.svg"
10235
url: "https://slack.cloudposse.com"
10336
- name: "Discourse Forum"
10437
image: "https://img.shields.io/discourse/https/ask.sweetops.com/posts.svg"
10538
url: "https://ask.sweetops.com/"
10639

107-
# List any related terraform modules that this module may be used with or that this module depends on.
10840
related:
109-
- name: "terraform-null-label"
110-
description: "Terraform module designed to generate consistent names and tags for resources. Use terraform-null-label to implement a strict naming convention."
111-
url: "https://github.com/cloudposse/terraform-null-label"
112-
113-
# List any resources helpful for someone to get started. For example, link to the hashicorp documentation or AWS documentation.
114-
references:
41+
- name: "lambda-github-action-token-rotator"
42+
description: "The Lambda function this module installs"
43+
url: "https://github.com/cloudposse/lambda-github-action-token-rotator"
44+
45+
# References
46+
#references:
47+
# - name: "Wikipedia - Test Harness"
48+
# description: 'The `build-harness` is similar in concept to a "Test Harness"'
49+
# url: "https://en.wikipedia.org/wiki/Test_harness"
50+
51+
# Screenshots
52+
#screenshots:
53+
# - name: "demo"
54+
# description: "Example of using the `build-harness` to build a docker image"
55+
# url: "https://cdn.rawgit.com/cloudposse/build-harness/master/docs/demo.svg"
11556

11657
# Short description of this project
11758
description: |-
118-
Short
119-
description
59+
This module deploys a [lambda function](https://github.com/cloudposse/lambda-github-action-token-rotator) that runs as
60+
a GitHub Application and periodically gets a new GitHub Runner Registration Token from the GitHub API. This token is
61+
then stored in AWS Systems Manager Parameter Store.
12062
12163
# Introduction to the project
122-
introduction: |-
123-
This is an introduction.
64+
#introduction: |-
65+
# This is an introduction.
12466

125-
# How to use this module. Should be an easy example to copy and paste.
67+
# How to use this project
12668
usage: |-
127-
For a complete example, see [examples/complete](examples/complete).
128-
129-
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest)
130-
(which tests and deploys the example on AWS), see [test](test).
131-
13269
```hcl
133-
# Create a standard label resource. See [null-label](https://github.com/cloudposse/terraform-null-label/#terraform-null-label--)
134-
module "label" {
135-
source = "cloudposse/label/null"
136-
# Cloud Posse recommends pinning every module to a specific version, though usually you want to use the current one
137-
# version = "x.x.x"
138-
139-
namespace = "eg"
140-
name = "example"
141-
}
142-
143-
module "example" {
144-
source = "cloudposse/*****/aws"
145-
# Cloud Posse recommends pinning every module to a specific version
146-
# version = "x.x.x"
147-
148-
example = "Hello world!"
149-
150-
context = module.label.this
70+
module "github_action_token_rotator" {
71+
source = "cloudposse/github-action-token-rotator/aws"
72+
# Cloud Posse recommends pinning every module to a specific version
73+
# version = "x.x.x"
74+
parameter_store_token_path = "/github/runners/cloudposse/registrationToken"
75+
parameter_store_private_key_path = "/github/runners/cloudposse/privateKey"
76+
github_app_id = "111111"
77+
github_app_installation_id = "22222222"
78+
github_org = "cloudposse"
15179
}
15280
```
15381
15482
# Example usage
155-
examples: |-
156-
Here is an example of using this module:
157-
- [`examples/complete`](https://github.com/cloudposse/terraform-example-module/) - complete example of using this module
83+
#examples: |-
84+
# Here are some real world examples:
85+
# TODO: Add examples
15886

15987
# How to get started quickly
16088
quickstart: |-
161-
Here's how to get started...
162-
163-
# Other files to include in this README from the project folder
164-
include:
165-
- "docs/targets.md"
166-
- "docs/terraform.md"
89+
1. Browse to https://github.com/organizations/{YOUR_ORG}/settings/apps and click the New GitHub App button
90+
1. Set the name to "GitHub Action Token Rotator"
91+
1. Set the Homepage URL to `https://github.com/cloudposse/lambda-github-action-token-rotator`
92+
1. Uncheck the Active checkbox under the Webhook heading
93+
1. Select `Read and write` under Organization permissions -> Self-hosted runners
94+
1. Click the Create GitHub App button at the bottom of the page
95+
1. Under the `Client secrets` section, click the `Generate a new client secret` button
96+
1. Copy the Client secret to a safe place, it will be needed to install the app
97+
1. Under the `Private key` section, click the `Generate a private key` button
98+
1. Download the private key to a safe place, it will be needed to install the app
99+
1. Convert the private key to a PEM file using the following command:
100+
`openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in {DOWNLOADED_FILE_NAME}.pem -out private-key-pkcs8.key`
101+
1. Base64 encode the private key using the following command:
102+
`cat private-key-pkcs8.key | base64`
103+
1. Copy the Base64 value to AWS SSM Parameter store at `/github/runners/${YOUR_GITHUB_ORG}/privateKey`
167104
168105
# Contributors to this project
169106
contributors:
170-
- name: "Erik Osterman"
171-
github: "osterman"
107+
- name: "Matt Calhoun"
108+
github: "mcalhoun"

0 commit comments

Comments
 (0)