vandium-io / aws-param-store Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
AWS returns an error with message "Member must have length less than or equal to 10"
GIVEN that parent applicaiton has aws-param-store
in their production dependencies
WHEN running npm install --production
THEN package requires aws-sdk
AND actually it is not present.
proposed solution: have aws-sdk
as a dependency.
If I want to a build a simple CLI on top of this, would be good for me to have the full get/put APIs:
https://docs.aws.amazon.com/cli/latest/reference/ssm/get-parameters-by-path.html
Thoughts?
Hi, I use the sample code and get a timeout after 3 seconds.
exports.handler = (event, context, callback) => {
console.log("running");
let awsParamStore = require( 'aws-param-store' );
try {
let parameters = awsParamStore.getParametersSync( ['/folder/var'], { region: 'us-east-1' } );
console.log( parameters );
}
catch( err ) {
console.log( err );
}
}
I don't think it's a permissions or AWS config issue as the exact same lambda if I run this code it works:
var AWS = require('aws-sdk');
var ssm = new AWS.SSM();
exports.handler = function(event, context) {
getParameterFromSystemManager(function(){
console.log('done');
context.done(null, 'Hello from Lambda');
});
};
function getParameterFromSystemManager(callback) {
// Fetches a parameter called REPO_NAME from SSM parameter store.
// Requires a policy for SSM:GetParameter on the parameter being read.
var params = {
Name: '/folder/var',
/* required */
WithDecryption: /*true ||*/ false
};
console.log('in the getParameterFromSystemManager function')
var request = ssm.getParameter(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
callback();
});
}
Replace aws-sdk with @aws-sdk/client-ssm
Reducing from
└─ Unpacked Size 80.4 MB
to
└─ Unpacked Size 4.72 MB
add typings either in definitely typed or this project
I was attempting to call getParametersByPath
in a TypeScript project and it told me path
needed to be an array. The docs indicate that it's a string though. I'm not sure if the types are wrong or the docs. I added a @ts-ignore
comment to that line and passed a string and it seemed to work.
Hi,
This is a feature request to add querying parameters by name instead of by path.
I looked at the code and played around with different calls but couldn't achieve the same functionality as aws ssm get-parameters --name 'my-parameter'
.
I also played around with different libraries similar to this one and this is by far the best implementation I've tried, hence my decision to open an issue here.
Thanks,
Ronald
So I've been happily using the async versions of getParameter
and getParametersByPath
without issue like this:
const p = await ssm.getParameter(path, {
credentials: new AWS.SharedIniFileCredentials({profile: environment})
});
console.log(p);
But when I use the sync version I get a "missing credentials in config" error.
const p = ssm.getParameterSync(path, {
credentials: new AWS.SharedIniFileCredentials({profile: environment})
});
console.log(p)
I'm guessing it has to do with how SharedIniFileCredentials is resolved or surely this would have already been reported. Not sure how most people are passing their credentials to this library...
Have tried different combinations of recursive/decrypted/sync/async, nothing worked, no errors, empty response.
aws-param-store 1.1.0
aws-sdk 2.202.0
node v8.8.1
Ended up using native aws sdk.
const AWS_SSM = require('aws-sdk/clients/ssm')
var ssm = new AWS_SSM({region: 'ca-central-1'})
ssm.getParameters({
Names: [
'/test',
]
}, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
})
Error: The security token included in the request is invalid
at ParameterQuery.executeSync (platform-automation-tests/node_modules/aws-param-store/lib/param_query.js:139:19)
at Object.getParameterSync (platform-automation-tests/node_modules/aws-param-store/lib/index.js:54:10)
at Object. (platform-automation-tests/src/test/utils/AwsParamStore.js:7:36)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
I'm getting the above error when I run awsParamStore.getParameterSync(). Is there some configuration that is required?
It looks like index.js is not pre-compiled to ES5. I receive this error when I try to use it in an app using create-react-app:
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
./node_modules/aws-param-store/lib/index.js:5
Read more here: http://bit.ly/2tRViJ9
I'd provide a solution, but am unsure exactly what that would be because I'm relatively new to create-react-app and the relationship between this project and ES5/ES6.
It might be worth adding comment into readme that it needs AWS_REGION
e.g.
export AWS_REGION=eu-west-1
This happens on AWS lambda Node 14.x. Running the same code on our ECS service did not result in this error. Not sure exactly what is causing it, but switching to the async call getParameter
fixed the error for us, so seems like there is a bug in the sync version of getParameter.
Here's the full stack trace, but it's not very helpful:
{
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Unexpected end of JSON input",
"stack": [
"Runtime.UserCodeSyntaxError: SyntaxError: Unexpected end of JSON input",
" at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1063:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)",
" at Module.load (internal/modules/cjs/loader.js:928:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:769:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)",
" at internal/main/run_main_module.js:17:47"
]
}
Hiya,
It seems like things are inactive here, so I have forked and added ask-sdkv3 support at https://github.com/coggle/aws-param-store (published as aws-param-store-sdkv3
), adding an explicit dependency on @aws-sdk/client-ssm
but if you are interested in merging this please do.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.