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/pkg/alpha.dagger.io/terraform/tests/terraform.cue
Andrea Luzzardi 282759c0e5 cue modules: move stdlib to pkg/alpha.dagger.io
In preparation for Europa, we will vendor multiple CUE modules:

- `pkg/alpha.dagger.io`: legacy non-europa packages
- `pkg/dagger.io`: core Europa packages
- `pkg/universe.dagger.io`: Europa universe

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2022-01-11 13:16:37 -08:00

74 lines
1.4 KiB
CUE

package terraform
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op"
"alpha.dagger.io/alpine"
)
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: #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
}
}
}