Open operatorequals opened 2 years ago
Thank you for the PR, @operatorequals! Will review it shortly.
Just added support for parse-json
as I also needed it in my usecase.
With json
secrets as:
{
"key1":"value1",
"key2":"value2"
}
- name: Read secrets from AWS Secrets Manager into environment variables
uses: operatorequals/aws-secrets-manager-action@feature/custom_envvar_names
with:
parse-json: true
secrets: |
json | CUSTOM_ENV_VAR_JSON
populates CUSTOM_ENV_VAR_JSON_KEY1
and CUSTOM_ENV_VAR_JSON_KEY2
Thank you for the PR, @operatorequals! Will review it shortly.
Hello @abhilash1in ! Added an extra feature here, can you please re-trigger the tests? I am currently using this code in my builds and it works properly!
Is it possible for this to also support having no prefix as well? So in your example, if you had:
{
"key1":"value1",
"key2":"value2"
}
you'd get an environment with the values:
KEY1=value1
KEY2=value2
Apologies if this is already supported, I couldn't find any mention of it.
Thanks!
...actually, scratch my request -- I found a one-liner to do this for me; this is in Ruby but I expect it'd be similarly short in other languages:
- name: Sync ENV to AWS secrets for branch
run: |
aws secretsmanager get-secret-value --secret-id ${{ inputs.aws_secret_name }} --query SecretString --output text | ruby script/secret_to_env.rb >> $GITHUB_ENV
where script/secret_to_env.rb
is just the following (my keys are already uppercased and underscored):
require 'json'
JSON.parse($stdin.read).each { |k, v| puts "#{k}=#{v}" }
Is it possible for this to also support having no prefix as well? So in your example, if you had:
{ "key1":"value1", "key2":"value2" }
you'd get an environment with the values:
KEY1=value1 KEY2=value2
Apologies if this is already supported, I couldn't find any mention of it.
Thanks!
Best you could do right now is:
json | _
and get keys like _KEY1
and _KEY2
.
Also a syntax like:
json |
must do exactly what you want!
@operatorequals just so I understand,
The syntax:
json |
Would be able to import json secrets without a prefix? I believe that's what would happen form checking the code, but I'm not sure.
I'd like to use this plug in, but need to be able to import json secrets with no prefix.
@operatorequals just so I understand,
The syntax:
json |
Would be able to import json secrets without a prefix? I believe that's what would happen form checking the code, but I'm not sure.
I'd like to use this plug in, but need to be able to import json secrets with no prefix.
Try it! It should work as I explained!
@abhilash1in Is it good enough to merge back to master and bump a new version?
This PR solves https://github.com/abhilash1in/aws-secrets-manager-action/issues/42, enabling putting secrets under specific Environment Variable names. It does not work with Wildcard paths and throws an appropriate error about it.