This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/stdlib/.dagger/env/terraform/plan/terraform.cue
Solomon Hykes d7a805f42b stdlib: move all imports to alpha.dagger.io
Signed-off-by: Solomon Hykes <solomon@dagger.io>
2021-06-25 10:31:22 +00:00

75 lines
1.5 KiB
CUE

package terraform
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op"
"alpha.dagger.io/alpine"
"alpha.dagger.io/terraform"
)
TestData: dagger.#Artifact @dagger(input)
TestConfig: awsConfig: {
accessKey: dagger.#Secret @dagger(input)
secretKey: dagger.#Secret @dagger(input)
region: "us-east-2"
}
#TestGetConfig: {
accessKey: dagger.#Secret
secretKey: dagger.#Secret
visibleAccessKey: string
visibleSecretKey: string
#up: [
op.#Load & {from: alpine.#Image & {
package: {
bash: true
jq: true
}
}},
op.#Exec & {
always: true
args: ["/bin/bash", "-c", #"""
export ACCESS_KEY=$(cat /accessKey)
export SECRET_KEY=$(cat /secretKey)
jq --arg key0 'visibleAccessKey' --arg value0 "$ACCESS_KEY" \
--arg key1 'visibleSecretKey' --arg value1 "$SECRET_KEY" \
'. | .[$key0]=$value0 | .[$key1]=$value1' <<< '{}' > /out
"""#,
]
mount: {
"/accessKey": secret: accessKey
"/secretKey": secret: secretKey
}
},
op.#Export & {
source: "/out"
format: "json"
},
]
}
TestTerraform: {
config: #TestGetConfig & {
accessKey: TestConfig.awsConfig.accessKey
secretKey: TestConfig.awsConfig.secretKey
}
apply: terraform.#Configuration & {
source: TestData
env: {
AWS_ACCESS_KEY_ID: config.visibleAccessKey
AWS_SECRET_ACCESS_KEY: config.visibleSecretKey
AWS_DEFAULT_REGION: TestConfig.awsConfig.region
AWS_REGION: TestConfig.awsConfig.region
}
}
}