Skip to content
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

Updated quiz in 7.1.4 to match with the updated way of incorporating … #410

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Most of the time, you'll be able to find a Terraform provider for the platform y

Since this is a custom API the Ferrets have written, we will also need to make our own custom Terraform provider if we want to use Terraform to manage our resources. Knowing the structure of this API is crucial when attempting to write the provider. Before diving into creating the provider for this API, take some time looking over the [API ReadMe](https://github.com/liatrio/devops-bootcamp/blob/7a7b695f669f13a6894bad2220cf34d5a8785d09/examples/ch6/devops-api/README.md), as well as the accompanying scripts. Try to run the API locally and add some resources until you think you have a good understanding of how it works.

<div id="quizdown">
<div id="chapter-7/section-4/api-checkpoint.js" ></div>
<div class="quizdown">
<div id="chapter-7/7.1.4/api-checkpoint.js" ></div>
</div>

Now that we have a grasp on what it is we're attempting to have Terraform manage, we can start a deeper discussion of how we can write a Terraform provider to declaratively manage our resources within this API.
Expand All @@ -93,6 +93,10 @@ Creating a Terraform provider is hard. To help mitigate some of the difficulty,

2. Clone your repo. Navigate to `main.go` and change the provider address from `registry.terraform.io/hashicorp/scaffolding` to `liatr.io/terraform/devops-bootcamp`.

<div class="quizdown">
<div id="chapter-7/7.1.4/provider-name-checkpoint.js" ></div>
</div>

3. Delete the provided `GNUmakefile` and replace it with [this updated Makefile](https://github.com/liatrio/devops-bootcamp/blob/4503cf73612b1e5be73e4f9d13717d0e157c4d0f/examples/ch6/provider-setup/Makefile) and [helper script](https://github.com/liatrio/devops-bootcamp/blob/7364553501872567fe105dc27f3cf84dd3a11cf8/examples/ch6/provider-setup/.make-helper.sh). Run `make init` to initialize your repo.

4. Ensure that your provider executes correctly by running `go run main.go`. You should see the following output:
Expand Down Expand Up @@ -186,6 +190,10 @@ Also of note, the Hashicorp tutorial creates a coffee data source, but not a res

Once you've finished this, you should be able to declaratively manage your engineer resources in the API through Terraform!

<div class="quizdown">
<div id="chapter-7/7.1.4/end-of-engineer-checkpoint.js" ></div>
</div>

### Exercise 4: Testing

It's good practice to implement some testing for each of your resources. Since you have a working resource now, you should implement some testing for it. Follow the ["Implement automated testing"](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework/providers-plugin-framework-acceptance-testing) section of the Hashicorp tutorial to add some acceptance testing to your provider.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const rawQuizdown = `
---
primaryColor: '#24ae1dff'
shuffleAnswers: true
---
# What would the following request do?
Expand Down
32 changes: 32 additions & 0 deletions src/quizzes/chapter-7/7.1.4/end-of-engineer-checkpoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const rawQuizdown = `
---
shuffleAnswers: true
---
# What does the \`\`\`Read\`\`\` function of a data source do?

- [x] Refreshes the Terraform state based on the actual state of the resource in the API.
- [ ] Reads the configuration of your client and judges if it is correct.
- [ ] Queries your configured API for all resources.

# What is one difference between a schema and data model in the context of the Hashicorp tutorial?

- [x] A schema uses Terraform types and a data model uses Go types.
- [ ] A schema uses Go types and a data model uses Terraform types.
- [ ] A schema is untyped and a data model is typed.
- [ ] A schema is typed and a data model is untyped.

# What is the purpose of a Schema for a resource?

- [x] It prepares the resource to accept data from the Terraform configuration and store order information in the Terraform state.
- [ ] It establishes a connection to the external API and queries it for the structure of API resources.
- [ ] It determines the order of resource creation.

# What is the purpose of the \`\`\`Update\`\`\` function for a resource?

- [x] To update the resource based on the Terraform plan.
- [ ] To update the Terraform plan.
- [ ] To update the resource based on the Terraform state.
- [ ] To update the Terraform state.
`;

export { rawQuizdown }
12 changes: 12 additions & 0 deletions src/quizzes/chapter-7/7.1.4/provider-name-checkpoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const rawQuizdown = `
---
shuffleAnswers: true
---
# Based on the provider address \`\`\`liatri.io/terraform/devops-bootcamp\`\`\`, what is the name of your provider?

- [x] devops-bootcamp
- [ ] liatri.io/terraform/devops-bootcamp
- [ ] liatri.io
`;

export { rawQuizdown }
Loading