Skip to content

Commit b4203b6

Browse files
aknyshosterman
andauthored
Add atmos terraform generate planfile command (#1214)
* updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * Update website/docs/cli/commands/terraform/terraform-generate-planfile.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]> * updates --------- Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
1 parent 48f4289 commit b4203b6

File tree

16 files changed

+806
-70
lines changed

16 files changed

+806
-70
lines changed

cmd/terraform_generate_planfile.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
e "github.com/cloudposse/atmos/internal/exec"
7+
u "github.com/cloudposse/atmos/pkg/utils"
8+
)
9+
10+
// terraformGeneratePlanfileCmd generates planfile for a terraform component.
11+
var terraformGeneratePlanfileCmd = &cobra.Command{
12+
Use: "planfile",
13+
Short: "Generate a planfile for a Terraform component",
14+
Long: "This command generates a `planfile` for a specified Atmos Terraform component.",
15+
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
16+
ValidArgsFunction: ComponentsArgCompletion,
17+
Run: func(cmd *cobra.Command, args []string) {
18+
handleHelpRequest(cmd, args)
19+
// Check Atmos configuration
20+
checkAtmosConfig()
21+
22+
err := e.ExecuteTerraformGeneratePlanfileCmd(cmd, args)
23+
if err != nil {
24+
u.PrintErrorMarkdownAndExit("", err, "")
25+
}
26+
},
27+
}
28+
29+
func init() {
30+
terraformGeneratePlanfileCmd.DisableFlagParsing = false
31+
AddStackCompletion(terraformGeneratePlanfileCmd)
32+
33+
terraformGeneratePlanfileCmd.PersistentFlags().StringP("file", "f", "", "Planfile name")
34+
terraformGeneratePlanfileCmd.PersistentFlags().String("format", "json", "Output format (`json` or `yaml`, `json` is default)")
35+
36+
err := terraformGeneratePlanfileCmd.MarkPersistentFlagRequired("stack")
37+
if err != nil {
38+
u.PrintErrorMarkdownAndExit("", err, "")
39+
}
40+
41+
terraformGenerateCmd.AddCommand(terraformGeneratePlanfileCmd)
42+
}

demo/screengrabs/demo-stacks.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ atmos terraform deploy --help
3232
atmos terraform generate --help
3333
atmos terraform generate backend --help
3434
atmos terraform generate backends --help
35+
atmos terraform generate planfile --help
3536
atmos terraform generate varfile --help
3637
atmos terraform generate varfiles --help
3738
atmos terraform shell --help

examples/quick-start-advanced/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG GEODESIC_OS=debian
66
# https://atmos.tools/
77
# https://github.com/cloudposse/atmos
88
# https://github.com/cloudposse/atmos/releases
9-
ARG ATMOS_VERSION=1.171.0
9+
ARG ATMOS_VERSION=1.172.0
1010

1111
# Terraform: https://github.com/hashicorp/terraform/releases
1212
ARG TF_VERSION=1.5.7

go.mod

Lines changed: 21 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)