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
Copy file name to clipboardExpand all lines: content/docs/fundamentals/introduction.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ How does it differentiate from these solutions?
34
34
35
35
1. It's 100% Open Source: SweetOps [is on GitHub](https://github.com/cloudposse) and is free to use with no strings attached under Apache 2.0.
36
36
1. It's comprehensive: SweetOps is not only about Terraform. It provides patterns and conventions for building cloud native platforms that are security focused, Kubernetes-based, and driven by continuous delivery.
37
-
1. It's community focused: SweetOps has [over 3400 users in Slack](https://sweetops.com/slack/), well-attended weekly office hours, and a [budding community forum](https://ask.sweetops.com/).
37
+
1. It's community focused: SweetOps has [over 9000 users in Slack](https://sweetops.com/slack/), well-attended weekly office hours, and a [budding community forum](https://ask.sweetops.com/).
Copy file name to clipboardExpand all lines: content/docs/intro.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Start with getting familiar with the [geodesic](/reference/tools.mdx#geodesic).
12
12
13
13
Get intimately familiar with docker inheritance and [multi-stage docker builds](/reference/best-practices/docker-best-practices.md#multi-stage-builds). We use this pattern extensively.
14
14
15
-
Check out our [terraform-aws-components](https://github.com/cloudposse/terraform-aws-components) for reference architectures to easily provision infrastructure
15
+
Check out our [terraform-aws-components](https://github.com/cloudposse/terraform-aws-components) for reference architectures to easily provision infrastructure.
16
16
17
17
## Tools
18
18
@@ -70,7 +70,7 @@ Review our [glossary](/category/glossary/) if there are any terms that are confu
70
70
71
71
File issues anywhere you find the documentation lacking by going to our [docs repo](https://github.com/cloudposse/docs).
72
72
73
-
Join our [Slack Community](https://cloudposse.com/slack/) and speak directly with the maintainers
73
+
Join our [Slack Community](https://cloudposse.com/slack/) and speak directly with the maintainers.
74
74
75
75
We provide "white glove" DevOps support. [Get in touch](/contact-us.md) with us today!
Copy file name to clipboardExpand all lines: content/docs/reference/best-practices/docker-best-practices.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,10 @@ Try to leverage the same base image in as many of your images as possible for fa
15
15
16
16
## Multi-stage Builds
17
17
18
-
There are two ways to leverage multi-stage builds.
18
+
There are two ways to leverage multi-stage builds:
19
19
20
-
1.*Build-time Environments* The most common application of multi-stage builds is for using a build-time environment for compiling apps, and then a minimal image (E.g. `alpine` or `scratch`) for distributing the resultant artifacts (e.g. statically-linked go binaries).
21
-
2.*Multiple-Inheritance* We like to think of "multi-stage builds" as a mechanism for "multiple inheritance" as it relates to docker images. While not technically the same thing, using mult-stage images, it's possible `COPY --from=other-image` to keep things very DRY.
20
+
1.*Build-time Environments* The most common application of multi-stage builds is for using a build-time environment for compiling apps, and then a minimal image (E.g. `alpine` or `scratch`) for distributing the resultant artifacts (e.g. statically-linked `go` binaries).
21
+
2.*Multiple-Inheritance* We like to think of "multi-stage builds" as a mechanism for "multiple inheritance" as it relates to docker images. While not technically the same thing, using multi-stage images makes it possible to`COPY --from=other-image` to keep things very DRY.
Copy file name to clipboardExpand all lines: content/docs/reference/best-practices/terraform-best-practices.md
+47-22Lines changed: 47 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,23 @@ conversion errors, and allows for future expansion without breaking changes.
100
100
Make as many fields as possible optional, provide defaults at every level of
101
101
nesting, and use `nullable = false` if possible.
102
102
103
+
:::caution Extra (or Misspelled) Fields in Object Inputs Will Be Silently Ignored
104
+
105
+
If you use an object with defaults as an input, Terraform will not give any
106
+
indication if the user provides extra fields in the input object. This is
107
+
particularly a problem if they misspelled an optional field name, because
108
+
the misspelled field will be silently ignored, and the default value the
109
+
user intended to override will silently be used. This is
110
+
[a limitation of Terraform](https://github.com/hashicorp/terraform/issues/29204#issuecomment-1989579801).
111
+
Furthermore, there is no way to add any checks for this situation, because
112
+
the input will have already been transformed (unexpected fields removed) by
113
+
the time any validation code runs. This makes using an object a trade-off
114
+
versus using separate inputs, which do not have this problem, or `type = any`
115
+
which allows you to write validation code to catch this problem and
116
+
additional code to supply defaults for missing fields.
117
+
118
+
:::
119
+
103
120
Reserve `type = any` for exceptional cases where the input is highly
104
121
variable and/or complex, and the module is designed to handle it. For
105
122
example, the configuration of a [Datadog synthetic test](https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/synthetics_test)
@@ -117,8 +134,9 @@ often use a large number of input variables of simple types. This is because
117
134
in the early development of Terraform, there was no good way to define
118
135
complex objects with defaults. However, now that Terraform supports complex
119
136
objects with field-level defaults, we recommend using a single object input
120
-
variable with such defaults to group related configuration. This makes the
121
-
interface easier to understand and use.
137
+
variable with such defaults to group related configuration, taking into consideration
138
+
the trade-offs listed in the [above caution](#use-objects-with-optional-fields-for-complex-inputs).
139
+
This makes the interface easier to understand and use.
However, using an object with defaults versus multiple simple inputs is not
173
+
without trade-offs, as explained in the [above caution](#use-objects-with-optional-fields-for-complex-inputs).
174
+
175
+
176
+
There are a few ways to mitigate this problem besides using separate inputs:
177
+
178
+
- If all the defaults are null or empty, you can use a `map(string)` input
179
+
variable and use the `keys` function to check for unexpected fields. This
180
+
catches errors, but has the drawback that it does not provide
181
+
documentation of what fields are expected.
182
+
- You can use `type = any` for inputs, but then you have to write the extra
183
+
code to validate the input and supply defaults for missing fields. You
184
+
should also document the expected fields in the input description.
185
+
- If all you are worried about is misspelled field names, you can make the
186
+
correctly spelled field names required, ensuring they are supplied.
187
+
Alternatively, if the misspelling is predictable, such as you have a field
188
+
named `minsize` but people are likely to try to supply `min_size`, you can
189
+
make the misspelled field name optional with a sentinel value and then
190
+
check for that value in the validation code.
191
+
192
+
154
193
### Use custom validators to enforce custom constraints
155
194
156
195
Use the `validation` block to enforce custom constraints on input variables.
@@ -277,7 +316,12 @@ configuration to a separate template file.
277
316
278
317
Linting helps to ensure a consistent code formatting, improves code quality and catches common errors with syntax.
279
318
280
-
Run `terraform fmt` before committing all code. Use a `pre-commit` hook to do this automatically. See [Terraform Tips & Tricks](/reference/best-practices/terraform-tips-tricks.md)
319
+
Run `terraform fmt` before committing all code. Use a `pre-commit` hook to
Copy file name to clipboardExpand all lines: content/docs/tutorials/geodesic-getting-started.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,9 +27,9 @@ Before we jump in, it's important to note that Geodesic is built around some adv
27
27
28
28
Let's talk about a few of the ways that one can run Geodesic. Our toolbox has been built to satisfy many use-cases, and each result in a different pattern of invocation:
29
29
30
-
1. You can **run standalone** Geodesic as a standard docker container using `docker run`. This enables you to get started quickly, to avoid fiddling with configuration or run one-off commands using some of the built-in tools.
30
+
1. You can **run standalone** Geodesic as a standard docker container using `docker run`. This enables you to quickly use most of the built-in tools. (Some tools require installing the wrapper script first, as explained in the next step.)
31
31
1. Example: `docker run -it --rm --volume $HOME:/localhost cloudposse/geodesic:latest-debian --login` opens a bash login shell (`--login` is our Docker `CMD` here; it's actually just [the arguments passed to the `bash` shell](https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html) which is our `ENTRYPOINT`) in our Geodesic container.
32
-
1. Example: `docker run -it --rm --volume $HOME:/localhost cloudposse/geodesic:latest-debian -c "terraform version"` executes the `terraform version` command as a oneoff and outputs the result.
32
+
1. Example: `docker run --rm cloudposse/geodesic:latest-debian -c "terraform version"` executes the `terraform version` command as a one-off and outputs the result.
33
33
1. You can **install** Geodesic onto your local machine using what we call the docker-bash pattern (e.g. `docker run ... | bash`). Similar to above, this enables a quickstart process but supports longer lived usage as it creates a callable script on your machine that enables reuse any time you want to start a shell.
34
34
1. Example: `docker run --rm cloudposse/geodesic:latest-debian init | bash -s latest-debian` installs `/usr/local/bin/geodesic` on your local machine which you can execute repeatedly via simply typing `geodesic`. In this example, we're pinning the script to use the `cloudposse/geodesic:latest-debian` docker image, but we could also pin to our own image or to a specific version.
35
35
1. Lastly, you can **build your own toolbox** on top of Geodesic. This is what SweetOps generally recommends to practitioners. We do this when we want to provide additional packages or customization to our team while building on the foundation that geodesic provides. This is simple to do by using Geodesic as your base image (e.g. `FROM cloudposse/geodesic:latest-debian`) in your own `Dockerfile`, adding your own Docker `RUN` commands or overriding environment variables, and then using `docker build` to create a new image that you distribute to your team. This is more advanced usage and we'll cover how to do this in a future how-to article.
@@ -90,9 +90,9 @@ terraform init
90
90
terraform apply -auto-approve
91
91
```
92
92
93
-
Sweet, you should see a successful `terraform apply` with some detailed `output`info on the original star wars hero! 😎
93
+
Sweet, you should see a successful `terraform apply` with some detailed `output`data on the original star wars hero! 😎
94
94
95
-
Just to show some simple usage of another tool in the toolbox, how about we pull apart that info and get that hero's name?
95
+
Just to show some simple usage of another tool in the toolbox, how about we parse that data and get that hero's name?
0 commit comments