Skip to content

Commit fabaa4f

Browse files
committed
Consolidate quickstarts into With Terraform
1 parent fd83543 commit fabaa4f

File tree

3 files changed

+226
-2
lines changed

3 files changed

+226
-2
lines changed

docs/CLAUDE.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Mintlify documentation
2+
3+
## Working relationship
4+
5+
- You can push back on ideas-this can lead to better documentation. Cite sources and explain your reasoning when you do so
6+
- ALWAYS ask for clarification rather than making assumptions
7+
- NEVER lie, guess, or make up information
8+
9+
## Project context
10+
11+
- Format: MDX files with YAML frontmatter
12+
- Config: docs.json for navigation, theme, settings
13+
- Components: Mintlify components
14+
15+
## Content strategy
16+
17+
- Document just enough for user success - not too much, not too little
18+
- Prioritize accuracy and usability of information
19+
- Make content evergreen when possible
20+
- Search for existing information before adding new content. Avoid duplication unless it is done for a strategic reason
21+
- Check existing patterns for consistency
22+
- Start by making the smallest reasonable changes
23+
24+
## Frontmatter requirements for pages
25+
26+
- title: Clear, descriptive page title
27+
- description: Concise summary for SEO/navigation
28+
29+
## Writing standards
30+
31+
- Second-person voice ("you")
32+
- Prerequisites at start of procedural content
33+
- Test all code examples before publishing
34+
- Match style and formatting of existing pages
35+
- Include both basic and advanced use cases
36+
- Language tags on all code blocks
37+
- Alt text on all images
38+
- Relative paths for internal links
39+
40+
## Git workflow
41+
42+
- NEVER use --no-verify when committing
43+
- Ask how to handle uncommitted changes before starting
44+
- Create a new branch when no clear branch exists for changes
45+
- Commit frequently throughout development
46+
- NEVER skip or disable pre-commit hooks
47+
48+
## Do not
49+
50+
- Skip frontmatter on any MDX file
51+
- Use absolute URLs for internal links
52+
- Include untested code examples
53+
- Make assumptions - always ask for clarification
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
title: "With Terraform"
3+
---
4+
5+
In this tutorial, you will set up Digger to automate terraform pull requests using Github Actions
6+
7+
# Prerequisites
8+
9+
- A GitHub repository with valid terraform code
10+
- Your cloud provider credentials:
11+
- For AWS: [Hashicorp's AWS tutorial](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-build)
12+
- For GCP: [Hashicorp's GCP tutorial](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/google-cloud-platform-build)
13+
14+
# Step 1: create your Digger account
15+
16+
Head to [ui.digger.dev](https://ui.digger.dev) and sign up using your preferred method.
17+
18+
You should see an empty dashboard after you sign up.
19+
20+
# Step 2: install the Digger GitHub App
21+
22+
Install the Digger [GitHub App](https://github.com/apps/digger-cloud/installations/select_target) into your repository.
23+
24+
<Note>
25+
Digger GitHub App does not need access to your cloud account, it just starts jobs in your CI. All sensitive data stays in your CI job.
26+
27+
You can also [self-host Digger orchestrator](/ce/self-host/deploy-docker) with a private GiHub app and issue your own token
28+
29+
</Note>
30+
31+
# Step 3: Create Action Secrets with cloud credentials
32+
33+
In GitHub repository settings, go to Secrets and Variables - Actions. Create the following secrets:
34+
35+
<Tabs>
36+
<Tab title="AWS">
37+
- `AWS_ACCESS_KEY_ID`
38+
- `AWS_SECRET_ACCESS_KEY`
39+
40+
You can also [use OIDC](/ce/cloud-providers/authenticating-with-oidc-on-aws) for AWS authentication.
41+
</Tab>
42+
<Tab title="GCP">
43+
- `GCP_CREDENTIALS` - contents of your GCP Service Account Key json file
44+
45+
You can also [use OIDC](/gcp/federated-oidc-access/) for GCP authentication.
46+
</Tab>
47+
</Tabs>
48+
49+
# Step 4: Create digger.yml
50+
51+
This file contains Digger configuration and needs to be placed at the root level of your repository. Assuming your terraform code is in the `prod` directory:
52+
53+
```
54+
projects:
55+
- name: production
56+
dir: prod
57+
```
58+
59+
# Step 5: Create Github Actions workflow file
60+
61+
Place it at `.github/workflows/digger_workflow.yml` (name is important!)
62+
63+
<Tabs>
64+
<Tab title="AWS">
65+
```yaml
66+
name: Digger Workflow
67+
68+
on:
69+
workflow_dispatch:
70+
inputs:
71+
spec:
72+
required: true
73+
run_name:
74+
required: false
75+
76+
run-name: '${{inputs.run_name}}'
77+
78+
jobs:
79+
digger-job:
80+
runs-on: ubuntu-latest
81+
permissions:
82+
contents: write # required to merge PRs
83+
actions: write # required for plan persistence
84+
id-token: write # required for workload-identity-federation
85+
pull-requests: write # required to post PR comments
86+
issues: read # required to check if PR number is an issue or not
87+
statuses: write # required to validate combined PR status
88+
89+
steps:
90+
- uses: actions/checkout@v4
91+
- name: ${{ fromJSON(github.event.inputs.spec).job_id }}
92+
run: echo "job id ${{ fromJSON(github.event.inputs.spec).job_id }}"
93+
- uses: diggerhq/digger@vLatest
94+
with:
95+
digger-spec: ${{ inputs.spec }}
96+
setup-aws: true
97+
setup-terraform: true
98+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
99+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
100+
env:
101+
GITHUB_CONTEXT: ${{ toJson(github) }}
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
```
104+
</Tab>
105+
<Tab title="GCP">
106+
```yaml
107+
name: Digger
108+
109+
on:
110+
workflow_dispatch:
111+
inputs:
112+
spec:
113+
required: true
114+
run_name:
115+
required: false
116+
117+
run-name: '${{inputs.run_name}}'
118+
119+
jobs:
120+
digger-job:
121+
name: Digger
122+
runs-on: ubuntu-latest
123+
permissions:
124+
contents: write # required to merge PRs
125+
actions: write # required for plan persistence
126+
id-token: write # required for workload-identity-federation
127+
pull-requests: write # required to post PR comments
128+
issues: read # required to check if PR number is an issue or not
129+
statuses: write # required to validate combined PR status
130+
steps:
131+
- uses: actions/checkout@v4
132+
- name: ${{ fromJSON(github.event.inputs.spec).job_id }}
133+
run: echo "job id ${{ fromJSON(github.event.inputs.spec).job_id }}"
134+
- id: 'auth'
135+
uses: 'google-github-actions/auth@v1'
136+
with:
137+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
138+
create_credentials_file: true
139+
- name: 'Set up Cloud SDK'
140+
uses: 'google-github-actions/setup-gcloud@v1'
141+
- name: 'Use gcloud CLI'
142+
run: 'gcloud info'
143+
- name: digger run
144+
uses: diggerhq/digger@vLatest
145+
with:
146+
digger-spec: ${{ inputs.spec }}
147+
setup-aws: false
148+
setup-terraform: true
149+
env:
150+
GITHUB_CONTEXT: ${{ toJson(github) }}
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
```
153+
154+
This workflow includes additional steps for GCP:
155+
- Authenticate into GCP using Google's official [Auth action](https://github.com/google-github-actions/auth). Note the `create_credentials_file: true` option; without it, subsequent steps that rely on [Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc) will not work.
156+
- Set up Google Cloud SDK for use in the subsequent steps via Google's official [Setup-gcloud action](https://github.com/google-github-actions/setup-gcloud)
157+
- Verify that GCP is configured correctly by running `gcloud info`
158+
</Tab>
159+
</Tabs>
160+
161+
# Step 6: Create a PR to verify that it works
162+
163+
Terraform will run an existing plan against your code.
164+
165+
Make any change to your terraform code e.g. add a blank line. An action run should start (you can see log output in Actions). After some time you should see output of Terraform Plan added as a comment to your PR.
166+
167+
Then you can add a comment like `digger apply` and shortly after apply output will be added as comment too.
168+
169+
# Demo repositories
170+
171+
- [AWS demo repo](https://github.com/diggerhq/quickstart-actions-aws)
172+
- [GCP demo repo](https://github.com/diggerhq/demo-conftest-gcp/)

docs/mint.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
{
4545
"group": "Getting Started",
4646
"pages": [
47-
"ce/getting-started/github-actions-+-aws",
48-
"ce/getting-started/github-actions-and-gcp"
47+
"ce/getting-started/with-terraform"
4948
]
5049
},
5150
{

0 commit comments

Comments
 (0)