-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Move to GitOps Config File #29
Changes from all commits
40d29ec
72e9836
166be85
fdd4613
a382920
07526f6
f158134
5452e71
9bc15aa
8eb5136
4b2b89f
ec074e3
0752f9b
36f9c4e
cf97a09
5d832f1
3b68c33
0c0dd8b
09df393
c1e8c03
cd92c1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,9 +50,29 @@ usage: |- | |
to allow GitHub to assume roles in AWS and then deploying both a Terraform Apply role and a Terraform State role. | ||
For Cloud Posse documentation on setting up GitHub OIDC, see our [`github-oidc-provider` component](https://docs.cloudposse.com/components/library/aws/github-oidc-provider/). | ||
|
||
In order to retrieve Terraform State, we configure an S3 Bucket to store plan files and a DynamoDB table to track plan metadata. Both will need to be deployed before running | ||
this action. For more on setting up those components, see the `gitops` component (__documentation pending__). This action will then use the [github-action-terraform-plan-storage](https://github.com/cloudposse/github-action-terraform-plan-storage) action to update these resources. | ||
In order to retrieve Terraform Plan Files (not to be confused with Terraform State files, e.g. `tfstate`), we configure an S3 Bucket to store plan files and a DynamoDB table to track plan metadata. Both need to be deployed before running | ||
this action. For more on setting up those components, see the [`gitops` component](https://docs.cloudposse.com/components/library/aws/gitops/). This action will then use the [github-action-terraform-plan-storage](https://github.com/cloudposse/github-action-terraform-plan-storage) action to update these resources. | ||
|
||
### Config | ||
|
||
The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. | ||
The config should have the following structure: | ||
|
||
```yaml | ||
atmos-version: 1.45.3 | ||
atmos-config-path: ./rootfs/usr/local/etc/atmos/ | ||
terraform-state-bucket: cptest-core-ue2-auto-gitops | ||
terraform-state-table: cptest-core-ue2-auto-gitops | ||
terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add this task to the backlog There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
terraform-plan-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops | ||
terraform-apply-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops | ||
terraform-version: 1.5.2 | ||
aws-region: us-east-2 | ||
enable-infracost: false | ||
sort-by: .stack_slug | ||
group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") | ||
``` | ||
|
||
### Workflow example | ||
|
||
```yaml | ||
|
@@ -75,20 +95,59 @@ usage: |- | |
plan: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Plan Atmos Component | ||
uses: cloudposse/github-action-atmos-terraform-apply@v1 | ||
- name: Terraform Apply | ||
uses: cloudposse/github-action-atmos-terraform-apply@v2 | ||
with: | ||
component: "foobar" | ||
stack: "plat-ue2-sandbox" | ||
component-path: "components/terraform/s3-bucket" | ||
terraform-apply-role: "arn:aws:iam::111111111111:role/acme-core-gbl-identity-gitops" | ||
terraform-state-bucket: "acme-core-ue2-auto-gitops" | ||
terraform-state-role: "arn:aws:iam::999999999999:role/acme-core-ue2-auto-gitops-gha" | ||
terraform-state-table: "acme-core-ue2-auto-gitops" | ||
aws-region: "us-east-2" | ||
``` | ||
|
||
### Migrating from `v1` to `v2` | ||
|
||
1. `v2` drops the `component-path` variable and instead fetches if directly from the [`atmos.yaml` file](https://atmos.tools/cli/configuration/) automatically. Simply remove the `component-path` argument from your invocations of the `cloudposse/github-action-atmos-terraform-apply` action. | ||
2. `v2` moves most of the `inputs` to the Atmos GitOps config path `./.github/config/atmos-gitops.yaml`. Simply create this file, transfer your settings to it, then remove the corresponding arguments from your invocations of the `cloudposse/github-action-atmos-terraform-apply` action. | ||
| name | | ||
|--------------------------| | ||
| `atmos-version` | | ||
| `atmos-config-path` | | ||
| `terraform-state-bucket` | | ||
| `terraform-state-table` | | ||
| `terraform-state-role` | | ||
| `terraform-plan-role` | | ||
| `terraform-apply-role` | | ||
| `terraform-version` | | ||
| `aws-region` | | ||
| `enable-infracost` | | ||
|
||
|
||
If you want the same behavior in `v2` as in `v1` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. | ||
|
||
```yaml | ||
- name: Terraform apply | ||
uses: cloudposse/github-action-atmos-terraform-apply@v2 | ||
with: | ||
atmos-gitops-config-path: ./.github/config/atmos-gitops.yaml | ||
component: "foobar" | ||
stack: "plat-ue2-sandbox" | ||
``` | ||
|
||
Which would produce the same behavior as in `v1`, doing this: | ||
|
||
```yaml | ||
- name: Terraform apply | ||
uses: cloudposse/github-action-atmos-terraform-apply@v1 | ||
with: | ||
component: "foobar" | ||
stack: "plat-ue2-sandbox" | ||
component-path: "components/terraform/s3-bucket" | ||
terraform-apply-role: "arn:aws:iam::111111111111:role/acme-core-gbl-identity-gitops" | ||
terraform-state-bucket: "acme-core-ue2-auto-gitops" | ||
terraform-state-role: "arn:aws:iam::999999999999:role/acme-core-ue2-auto-gitops-gha" | ||
terraform-state-table: "acme-core-ue2-auto-gitops" | ||
aws-region: "us-east-2" | ||
``` | ||
|
||
|
||
include: | ||
- "docs/github-action.md" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to rename these. These are not for the Terraform State Bucket. These are for the Terraform Plan File.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add this task to the backlog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goruha https://cloudposse.atlassian.net/browse/DEV-1537