Enforce JSON output format for aws command
This commit is contained in:
@@ -26,6 +26,7 @@ class Kamal::Secrets::Adapters::AwsSecretsManager < Kamal::Secrets::Adapters::Ba
|
|||||||
def get_from_secrets_manager(secrets, account: nil)
|
def get_from_secrets_manager(secrets, account: nil)
|
||||||
args = [ "aws", "secretsmanager", "batch-get-secret-value", "--secret-id-list" ] + secrets.map(&:shellescape)
|
args = [ "aws", "secretsmanager", "batch-get-secret-value", "--secret-id-list" ] + secrets.map(&:shellescape)
|
||||||
args += [ "--profile", account.shellescape ] if account
|
args += [ "--profile", account.shellescape ] if account
|
||||||
|
args += [ "--output", "json" ]
|
||||||
cmd = args.join(" ")
|
cmd = args.join(" ")
|
||||||
|
|
||||||
`#{cmd}`.tap do |secrets|
|
`#{cmd}`.tap do |secrets|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class AwsSecretsManagerAdapterTest < SecretAdapterTestCase
|
|||||||
test "fails when errors are present" do
|
test "fails when errors are present" do
|
||||||
stub_ticks.with("aws --version 2> /dev/null")
|
stub_ticks.with("aws --version 2> /dev/null")
|
||||||
stub_ticks
|
stub_ticks
|
||||||
.with("aws secretsmanager batch-get-secret-value --secret-id-list unknown1 unknown2 --profile default")
|
.with("aws secretsmanager batch-get-secret-value --secret-id-list unknown1 unknown2 --profile default --output json")
|
||||||
.returns(<<~JSON)
|
.returns(<<~JSON)
|
||||||
{
|
{
|
||||||
"SecretValues": [],
|
"SecretValues": [],
|
||||||
@@ -33,7 +33,7 @@ class AwsSecretsManagerAdapterTest < SecretAdapterTestCase
|
|||||||
test "fetch" do
|
test "fetch" do
|
||||||
stub_ticks.with("aws --version 2> /dev/null")
|
stub_ticks.with("aws --version 2> /dev/null")
|
||||||
stub_ticks
|
stub_ticks
|
||||||
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret/KEY1 secret/KEY2 secret2/KEY3 --profile default")
|
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret/KEY1 secret/KEY2 secret2/KEY3 --profile default --output json")
|
||||||
.returns(<<~JSON)
|
.returns(<<~JSON)
|
||||||
{
|
{
|
||||||
"SecretValues": [
|
"SecretValues": [
|
||||||
@@ -76,7 +76,7 @@ class AwsSecretsManagerAdapterTest < SecretAdapterTestCase
|
|||||||
test "fetch with string value" do
|
test "fetch with string value" do
|
||||||
stub_ticks.with("aws --version 2> /dev/null")
|
stub_ticks.with("aws --version 2> /dev/null")
|
||||||
stub_ticks
|
stub_ticks
|
||||||
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret secret2/KEY1 --profile default")
|
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret secret2/KEY1 --profile default --output json")
|
||||||
.returns(<<~JSON)
|
.returns(<<~JSON)
|
||||||
{
|
{
|
||||||
"SecretValues": [
|
"SecretValues": [
|
||||||
@@ -118,7 +118,7 @@ class AwsSecretsManagerAdapterTest < SecretAdapterTestCase
|
|||||||
test "fetch with secret names" do
|
test "fetch with secret names" do
|
||||||
stub_ticks.with("aws --version 2> /dev/null")
|
stub_ticks.with("aws --version 2> /dev/null")
|
||||||
stub_ticks
|
stub_ticks
|
||||||
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret/KEY1 secret/KEY2 --profile default")
|
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret/KEY1 secret/KEY2 --profile default --output json")
|
||||||
.returns(<<~JSON)
|
.returns(<<~JSON)
|
||||||
{
|
{
|
||||||
"SecretValues": [
|
"SecretValues": [
|
||||||
@@ -159,7 +159,7 @@ class AwsSecretsManagerAdapterTest < SecretAdapterTestCase
|
|||||||
test "fetch without account option omits --profile" do
|
test "fetch without account option omits --profile" do
|
||||||
stub_ticks.with("aws --version 2> /dev/null")
|
stub_ticks.with("aws --version 2> /dev/null")
|
||||||
stub_ticks
|
stub_ticks
|
||||||
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret/KEY1 secret/KEY2")
|
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret/KEY1 secret/KEY2 --output json")
|
||||||
.returns(<<~JSON)
|
.returns(<<~JSON)
|
||||||
{
|
{
|
||||||
"SecretValues": [
|
"SecretValues": [
|
||||||
|
|||||||
Reference in New Issue
Block a user