Skip to content

Instantly share code, notes, and snippets.

@bgauduch
Created September 1, 2022 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgauduch/edd94e3129ec79a7864ad6002fe546b6 to your computer and use it in GitHub Desktop.
Save bgauduch/edd94e3129ec79a7864ad6002fe546b6 to your computer and use it in GitHub Desktop.
dagger test with Terraform
package terraform
import (
"dagger.io/dagger"
"dagger.io/dagger/core"
"universe.dagger.io/alpha/terraform"
)
dagger.#Plan & {
client: {
// Read env var containing inline JSON of the service account
env: G_APP_CRED: dagger.#Secret
// Write full action FS to local FS (:alembic:)
filesystem: {
"out.tfplan": {
write: contents: actions.plan.plan.output."/out.tfplan"
}
}
}
actions: {
plan: {
getCode: core.#Source & {
path: "."
}
init: terraform.#Init & {
source: getCode.output
}
plan: terraform.#Plan & {
env: {
// Export the google cloud cred to be used by Terraform
GOOGLE_CREDENTIALS: client.env.G_APP_CRED
}
source: init.output
}
// writePlan: core.#WriteFile & {
// input: dagger.#FS
// path: "tf.plan"
// contents: plan.output
// }
}
// dev: {
// initUpgrade: terraform.#Init & {
// source: getCode.output
// // passe "upgrade" arg !
// }
// }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment