-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read environment vars from SSM (#50)
- Loading branch information
1 parent
9b10f55
commit 80bb05c
Showing
26 changed files
with
230 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
__debug_bin**.exe | ||
terrable.exe | ||
samples/*/.terraform.lock.hcl | ||
samples/*/.terraform/* | ||
samples/**/*terraform.tfstate* | ||
/samples/**/*-package.zip | ||
.terrable/ | ||
dist/ | ||
__debug_bin* | ||
__debug_bin* | ||
|
||
terrable.exe | ||
terrable | ||
tests/terrable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package config | ||
|
||
type TerrableConfig struct { | ||
Handlers []HandlerMapping | ||
Handlers []HandlerMapping | ||
GlobalEnvironmentVariables map[string]string | ||
} | ||
|
||
type HandlerMapping struct { | ||
Name string | ||
Source string | ||
Http map[string]string | ||
Name string | ||
Source string | ||
Http map[string]string | ||
EnvironmentVariables map[string]string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = 0.1.9 | ||
version = 0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"version": 4, | ||
"terraform_version": "1.9.8", | ||
"serial": 1, | ||
"lineage": "3d39f946-6e89-d2de-0b1b-9ae70363b2e7", | ||
"outputs": {}, | ||
"resources": [], | ||
"check_results": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
[environment] | ||
TOML_VAR = "hello toml" | ||
|
||
[offline] | ||
file = "../samples/simple/simple-api.tf" | ||
module = "simple_api" | ||
|
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
GET http://127.0.0.1:8081/ | ||
HTTP 200 | ||
|
||
[Asserts] | ||
jsonpath "$.env.GLOBAL_ENV" == "global-env-var" | ||
jsonpath "$.env.ECHO_ENV" == "echo-env" | ||
|
||
GET http://127.0.0.1:8081/echo-no-env | ||
HTTP 200 | ||
|
||
[Asserts] | ||
jsonpath "$.env.GLOBAL_ENV" == "global-env-var" | ||
jsonpath "$.env.ECHO_ENV" not exists | ||
|
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package utils | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/config" | ||
"github.com/aws/aws-sdk-go-v2/service/ssm" | ||
) | ||
|
||
func initSSMClient() (*ssm.Client, error) { | ||
cfg, err := config.LoadDefaultConfig(context.Background()) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ssmClient := ssm.NewFromConfig(cfg) | ||
|
||
return ssmClient, nil | ||
} | ||
|
||
func FetchSSMParameter(parameterName string) (string, error) { | ||
ssmClient, err := initSSMClient() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
input := &ssm.GetParameterInput{ | ||
Name: aws.String(parameterName), | ||
WithDecryption: aws.Bool(true), | ||
} | ||
|
||
result, err := ssmClient.GetParameter(context.Background(), input) | ||
|
||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return *result.Parameter.Value, nil | ||
} |
Oops, something went wrong.