You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* added github app support
* added github_token variable for webhook
* updated example
* Add bootstrap option for github-complete example and move Github App docs to the main README
* Update examples/github-complete/README.md
Co-authored-by: Anton Babenko <[email protected]>
* fix terraform_deprecated_index warnings from tflint
Co-authored-by: Carlos Alexandre <[email protected]>
Co-authored-by: Michael Kania <[email protected]>
Co-authored-by: Carlos Alexandre <[email protected]>
Co-authored-by: Anton Babenko <[email protected]>
@@ -129,6 +129,39 @@ Make sure that both private and public subnets were created in the same set of a
129
129
130
130
If all provided subnets are public (no NAT gateway) then `ecs_service_assign_public_ip` should be set to `true`.
131
131
132
+
### Using GitHub App
133
+
An Atlantis GitHub App can be generated using multiple methods:
134
+
135
+
- You can follow Atlantis instructions depicted [here](https://www.runatlantis.io/docs/access-credentials.html#github-app). The Atlantis method mostly automates the GitHub App generation using [GitHub App Manifest](https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app-from-a-manifest), but you need an exposed endpoint to complete the process.
136
+
- The other method is to manually create the GitHub App as instructed [here](https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app).
137
+
1. You create a GitHub App and give it a name - that name must be unique across the world (you can change it later).
138
+
2. Provide a valid Homepage URL (this can be the atlantis server url, for instance https://atlantis.mydomain.com)
139
+
3. Provide a valid Webhook URL. The Atlantis webhook server path is located by default at https://atlantis.mydomain.com/events
140
+
4. Generate a Webhook Secret - this is used for Atlantis to trust the deliveries. This is your github_webhook_secret.
141
+
5. Generate a Private Key - this is your github_app_key
142
+
6. On the App's settings page (at the top) you find the App ID. This is your github_app_id
143
+
7. On the Permissions & Events you need to setup all the permissions and events according to Atlantis documentation
144
+
145
+
Now you need to install the App on your organization.
146
+
147
+
A self-provisioned GitHub App usually has two parts: the App and the Installation.
148
+
149
+
The App part is the first step and its where you setup all the requirements, such as authentication, webhook, permissions, etc...
150
+
The Installation part is where you add the created App to an organization/personal-account. It is on the installation page where you setup which repositories the application can access and receive events from.
151
+
152
+
Once you have your GitHub App registered you will be able to access/manage the required parameters:
153
+
154
+
- `atlantis_github_app_id`to identify the GitHub app.
155
+
- `atlantis_github_app_key`to interact with GitHub.
156
+
- `atlantis_github_webhook_secret`to receive and validate incoming webhook invocations from GitHub.
157
+
158
+
#### GitHub Personal Access Token (PAT) is no longer recommended
159
+
160
+
While still supported, the use of GitHub Personal Access Token (PAT) is no longer the recommended method in favor of GitHub App.
161
+
162
+
[GitHub Apps](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps) provide more control over repository access/permissions and does not require the use of bot accounts.
163
+
164
+
132
165
### Secure Atlantis with ALB Built-in Authentication
| <a name="input_atlantis_bitbucket_user_token"></a> [atlantis\_bitbucket\_user\_token](#input\_atlantis\_bitbucket\_user\_token) | Bitbucket token of the user that is running the Atlantis command | `string` | `""` | no |
314
348
| <a name="input_atlantis_bitbucket_user_token_ssm_parameter_name"></a> [atlantis\_bitbucket\_user\_token\_ssm\_parameter\_name](#input\_atlantis\_bitbucket\_user\_token\_ssm\_parameter\_name) | Name of SSM parameter to keep atlantis\_bitbucket\_user\_token | `string` | `"/atlantis/bitbucket/user/token"` | no |
315
349
| <a name="input_atlantis_fqdn"></a> [atlantis\_fqdn](#input\_atlantis\_fqdn) | FQDN of Atlantis to use. Set this only to override Route53 and ALB's DNS name. | `string` | `null` | no |
350
+
| <a name="input_atlantis_github_app_id"></a> [atlantis\_github\_app\_id](#input\_atlantis\_github\_app\_id) | GitHub App ID that is running the Atlantis command | `string` | `""` | no |
351
+
| <a name="input_atlantis_github_app_key"></a> [atlantis\_github\_app\_key](#input\_atlantis\_github\_app\_key) | GitHub App private key that is running the Atlantis command | `string` | `""` | no |
352
+
| <a name="input_atlantis_github_app_key_ssm_parameter_name"></a> [atlantis\_github\_app\_key\_ssm\_parameter\_name](#input\_atlantis\_github\_app\_key\_ssm\_parameter\_name) | Name of SSM parameter to keep atlantis\_github\_app\_key | `string` | `"/atlantis/github/app/key"` | no |
316
353
| <a name="input_atlantis_github_user"></a> [atlantis\_github\_user](#input\_atlantis\_github\_user) | GitHub username that is running the Atlantis command | `string` | `""` | no |
317
354
| <a name="input_atlantis_github_user_token"></a> [atlantis\_github\_user\_token](#input\_atlantis\_github\_user\_token) | GitHub token of the user that is running the Atlantis command | `string` | `""` | no |
318
355
| <a name="input_atlantis_github_user_token_ssm_parameter_name"></a> [atlantis\_github\_user\_token\_ssm\_parameter\_name](#input\_atlantis\_github\_user\_token\_ssm\_parameter\_name) | Name of SSM parameter to keep atlantis\_github\_user\_token | `string` | `"/atlantis/github/user/token"` | no |
@@ -328,6 +365,7 @@ allow_github_webhooks = true
328
365
| <a name="input_atlantis_repo_allowlist"></a> [atlantis\_repo\_allowlist](#input\_atlantis\_repo\_allowlist) | List of allowed repositories Atlantis can be used with | `list(string)` | n/a | yes |
329
366
| <a name="input_atlantis_security_group_tags"></a> [atlantis\_security\_group\_tags](#input\_atlantis\_security\_group\_tags) | Additional tags to put on the atlantis security group | `map(string)` | `{}` | no |
330
367
| <a name="input_atlantis_version"></a> [atlantis\_version](#input\_atlantis\_version) | Verion of Atlantis to run. If not specified latest will be used | `string` | `"latest"` | no |
368
+
| <a name="input_atlantis_write_git_creds"></a> [atlantis\_write\_git\_creds](#input\_atlantis\_write\_git\_creds) | Write out a .git-credentials file with the provider user and token to allow cloning private modules over HTTPS or SSH | `string` | `"true"` | no |
331
369
| <a name="input_azs"></a> [azs](#input\_azs) | A list of availability zones in the region | `list(string)` | `[]` | no |
332
370
| <a name="input_certificate_arn"></a> [certificate\_arn](#input\_certificate\_arn) | ARN of certificate issued by AWS ACM. If empty, a new ACM certificate will be created and validated using Route53 DNS | `string` | `""` | no |
333
371
| <a name="input_cidr"></a> [cidr](#input\_cidr) | The CIDR block for the VPC which will be created if `vpc_id` is not specified | `string` | `""` | no |
Copy file name to clipboardExpand all lines: examples/github-complete/README.md
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,27 @@
1
-
# Complete Atlantis example with GitHub Webhooks
1
+
# Complete Atlantis example with GitHub App and Webhooks
2
2
3
3
Configuration in this directory creates the necessary infrastructure and resources for running Atlantis on Fargate plus GitHub repository webhooks configured to Atlantis URL.
4
4
5
5
An existing Route53 hosted zone and domain is required to deploy this example.
6
6
7
-
GitHub's personal access token can be generated at https://github.com/settings/tokens
8
-
9
7
## Usage
10
8
11
-
To run this code you need to copy `terraform.tfvars.sample` into `terraform.tfvars` and update the values locally or specify them using environment variables (`TF_VAR_github_token=xxx`, `TF_VAR_github_owner=xxx`, etc.). Once ready, execute:
9
+
To run this code you need to copy `terraform.tfvars.sample` into `terraform.tfvars` and update the values locally or specify them using environment variables (`TF_VAR_github_app_id=xxx`, `TF_VAR_github_owner=xxx`, etc.). Ensure that `bootstrap_github_app` is `true`. Once ready, execute:
12
10
13
11
```bash
14
12
$ terraform init
15
13
$ terraform plan
16
14
$ terraform apply
17
15
```
18
16
17
+
Terraform will output a URL to setup a new Github App via Atlantis, which should look something like https://$ATLANTIS_HOST/github-app/setup. Open that URL and go through the setup process. Before closing the window, click the link to install the new GitHub App on you repositories and copy the values `github_app_id`, `github_app_key`, and `github_webhook_secret` into `terraform.tfvars`. You should also set `bootstrap_github_app` to `false` . Now execute:
18
+
19
+
```bash
20
+
$ terraform plan
21
+
$ terraform apply
22
+
23
+
```
24
+
19
25
Note - if you receive the following error when running apply:
20
26
21
27
`Error: InvalidParameterException: The new ARN and resource ID format must be enabled to add tags to the service. Opt in to the new format and try again. "atlantiscomplete"`
@@ -45,7 +51,6 @@ Go to https://eu-west-1.console.aws.amazon.com/ecs/home?region=eu-west-1#/settin
| <aname="input_alb_ingress_cidr_blocks"></a> [alb\_ingress\_cidr\_blocks](#input\_alb\_ingress\_cidr\_blocks)| List of IPv4 CIDR ranges to use on all ingress rules of the ALB - use your personal IP in the form of `x.x.x.x/32` for restricted testing |`list(string)`| n/a | yes |
69
+
| <aname="input_bootstrap_github_app"></a> [bootstrap\_github\_app](#input\_bootstrap\_github\_app)| Flag to configure Atlantis to bootstrap a new Github App |`bool`| n/a | yes |
64
70
| <aname="input_domain"></a> [domain](#input\_domain)| Route53 domain name to use for ACM certificate. Route53 zone for this domain should be created in advance |`string`| n/a | yes |
71
+
| <aname="input_github_app_id"></a> [github\_app\_id](#input\_github\_app\_id)| GitHub App ID that is running the Atlantis command |`string`| n/a | yes |
72
+
| <aname="input_github_app_key"></a> [github\_app\_key](#input\_github\_app\_key)| The PEM encoded private key for the GitHub App |`string`| n/a | yes |
| <aname="input_github_repo_names"></a> [github\_repo\_names](#input\_github\_repo\_names)| List of Github repositories that should be monitored by Atlantis |`list(string)`| n/a | yes |
| <aname="input_github_user"></a> [github\_user](#input\_github\_user)| Github user for Atlantis to utilize when performing Github activities |`string`| n/a | yes |
| <aname="output_atlantis_github_app_setup_url"></a> [atlantis\_github\_app\_setup\_url](#output\_atlantis\_github\_app\_setup\_url)| URL to create a new Github App with Atlantis |
74
82
| <aname="output_atlantis_repo_allowlist"></a> [atlantis\_repo\_allowlist](#output\_atlantis\_repo\_allowlist)| Git repositories where webhook should be created |
75
83
| <aname="output_atlantis_url"></a> [atlantis\_url](#output\_atlantis\_url)| URL of Atlantis |
76
84
| <aname="output_ecs_task_definition"></a> [ecs\_task\_definition](#output\_ecs\_task\_definition)| Task definition for ECS service (used for external triggers) |
0 commit comments