Skip to content

Commit

Permalink
add ssh key for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
fanny-jiang committed Feb 15, 2024
1 parent 09b0988 commit 1f1e47d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ e2e:
# compare_to: "refs/heads/main"
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner:95dca87f269a
tags: ["arch:amd64"]
variables:
AWS_KEYPAIR_NAME: datadog-agent-ci
AWS_PRIVATE_KEY_FILE: $CI_PROJECT_DIR/ssh_key
before_script:
# Update awscli v2
- aws --version
Expand All @@ -23,6 +26,11 @@ e2e:
- mkdir -p ~/.aws
- set +x
- export GITHUB_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.helm-charts.github_token --with-decryption --query "Parameter.Value" --out text)
- aws ssm get-parameter --region us-east-1 --name ci.helm-charts.ssh_key --with-decryption --query "Parameter.Value" --out text > $AWS_PRIVATE_KEY_FILE
- set -x
# Without the newline ssh silently fails and moves on to try other auth methods
- echo "" >> $AWS_PRIVATE_KEY_FILE
- chmod 600 $AWS_PRIVATE_KEY_FILE
- aws ssm get-parameter --region us-east-1 --name ci.helm-charts.e2e-agent-qa-profile --with-decryption --query "Parameter.Value" --out text >> ~/.aws/config
- set -x
- export AWS_PROFILE=agent-qa-ci
Expand Down
10 changes: 6 additions & 4 deletions test/common/common_e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import (
"k8s.io/client-go/tools/remotecommand"
)

var defaultLocalPulumiConfigs = runner.ConfigMap{
var defaultPulumiConfigs = runner.ConfigMap{
"ddinfra:aws/defaultKeyPairName": auto.ConfigValue{Value: os.Getenv("AWS_KEYPAIR_NAME")},
}
var defaultCIPulumiConfigs = runner.ConfigMap{
"aws:skipCredentialsValidation": auto.ConfigValue{Value: "true"},
"aws:skipMetadataApiCheck": auto.ConfigValue{Value: "false"},
"aws:skipCredentialsValidation": auto.ConfigValue{Value: "true"},
"aws:skipMetadataApiCheck": auto.ConfigValue{Value: "false"},
"ddinfra:aws/defaultPrivateKeyPath": auto.ConfigValue{Value: os.Getenv("AWS_PRIVATE_KEY_FILE")},
}

type E2EEnv struct {
Expand Down Expand Up @@ -101,6 +102,7 @@ func SetupConfig() (runner.ConfigMap, error) {
res := runner.ConfigMap{}
configs := parseE2EConfigParams()
if os.Getenv("E2E_PROFILE") == "ci" {
res.Merge(defaultPulumiConfigs)
res.Merge(defaultCIPulumiConfigs)
} else {
// use "local" E2E profile for local testing
Expand All @@ -111,7 +113,7 @@ func SetupConfig() (runner.ConfigMap, error) {
if !e2eApiKeyBool || !e2eAppKeyBool || !e2eAwsKeypairNameBool {
return nil, fmt.Errorf("missing required environment variables. Must set `E2E_API_KEY`, `E2E_APP_KEY`, and `AWS_KEYPAIR_NAME` for the local E2E profile")
} else {
res.Merge(defaultLocalPulumiConfigs)
res.Merge(defaultPulumiConfigs)
}
}

Expand Down

0 comments on commit 1f1e47d

Please sign in to comment.