Skip to content

Commit

Permalink
Merge branch 'main' into wing-learn-by
Browse files Browse the repository at this point in the history
  • Loading branch information
boyney123 authored Sep 10, 2024
2 parents e062ca3 + ed06edb commit 68104d6
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions versioned_docs/version-latest/08-guides/02-ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
role-session-name: gh-actions-winglang # makes it easy to identify, e.g. in AWS Cloudtrail
aws-region: ${{ env.AWS_REGION }}
- name: Deploy Winglang App
uses: winglang/wing-github-action/actions/deploy@v0.1.0
uses: winglang/wing-github-action/actions/deploy@main
with:
entry: main.w
target: 'tf-aws'
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
role-session-name: gh-actions-winglang
aws-region: ${{ env.AWS_REGION }}
- name: Terraform Plan
uses: winglang/wing-github-action/actions/pull-request-diff@v0.1.0
uses: winglang/wing-github-action/actions/pull-request-diff@main
with:
entry: main.w
target: 'tf-aws'
Expand All @@ -123,24 +123,26 @@ Most users will find using the Wing GitHub Action within GitHub Actions as the s
Refer to the following Github Action workflow as a template to define your customized workflow. For detailed instructions, please refer to the Github Actions [documentation](https://docs.github.com/en/actions).
#### Backend Plugin
#### Backend Platform
Add the following file to your application root directory as `plugin.s3-backend.js`. This will be used in the Github Action workflow during the `wing compile` step. Learn more about this in the [Terraform Backend guide](./01-terraform-backend.md)
Add the following file to your application root directory as `platform.s3-backend.js`. This will be used in the Github Action workflow during the `wing compile` step. Learn more about this in the [Terraform Backend guide](./01-terraform-backend.md)

```
// plugin.s3-backend.js
exports.postSynth = function(config) {
if (!process.env.TF_BACKEND_BUCKET) {throw new Error("env var TF_BACKEND_BUCKET not set")}
if (!process.env.TF_BACKEND_BUCKET_REGION) {throw new Error("env var TF_BACKEND_BUCKET_REGION not set")}
if (!process.env.TF_BACKEND_STATE_FILE) {throw new Error("env var TF_BACKEND_STATE_FILE not set")}
config.terraform.backend = {
s3: {
bucket: process.env.TF_BACKEND_BUCKET,
region: process.env.TF_BACKEND_BUCKET_REGION,
key: process.env.TF_BACKEND_STATE_FILE
// platform.s3-backend.js
exports.Platform = class TFBackend {
postSynth(config) {
if (!process.env.TF_BACKEND_BUCKET) {throw new Error("env var TF_BACKEND_BUCKET not set")}
if (!process.env.TF_BACKEND_BUCKET_REGION) {throw new Error("env var TF_BACKEND_BUCKET_REGION not set")}
if (!process.env.TF_BACKEND_STATE_FILE) {throw new Error("env var TF_BACKEND_STATE_FILE not set")}
config.terraform.backend = {
s3: {
bucket: process.env.TF_BACKEND_BUCKET,
region: process.env.TF_BACKEND_BUCKET_REGION,
key: process.env.TF_BACKEND_STATE_FILE
}
}
return config;
}
return config;
}
```
Expand Down Expand Up @@ -181,7 +183,7 @@ permissions:

env:
AWS_REGION: "us-east-1"
# The following values are used in the backend plugin which
# The following values are used in the backend platform which
# is used in the `wing compile` step
TF_BACKEND_BUCKET: "my-terraform-state-bucket-with-a-globally-unique-name"
TF_BACKEND_BUCKET_REGION: "us-east-1"
Expand All @@ -202,7 +204,7 @@ jobs:
- name: Install Dependencies
run: npm ci
- name: Compile
run: wing compile -t tf-aws --plugins=plugin.s3-backend.js main.w
run: wing compile -t tf-aws -t platform.s3-backend.js main.w
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -228,7 +230,7 @@ Consider adding Winglang simulator tests as an intermediate step in your workflo
- name: Run Tests
run: wing test main.w
- name: Compile
run: wing compile -t tf-aws --plugins=plugin.s3-backend.js main.w
run: wing compile -t tf-aws -t platform.s3-backend.js main.w
# ...
```
Expand All @@ -241,7 +243,7 @@ Consider integrating third-party Terraform analysis tools for more comprehensive
- name: Install Dependencies
run: npm ci
- name: Compile
run: wing compile -t tf-aws --plugins=plugin.s3-backend.js main.w
run: wing compile -t tf-aws -t platform.s3-backend.js main.w
- name: Check Terraform Config
run: cd ./target/main.tfaws && your-tf-tool
# ...
Expand Down

0 comments on commit 68104d6

Please sign in to comment.