Fazi
08/06/2021, 10:40 AMAWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
. I ran aws configure
in the command line and set both of these, however, when I print the environment in my lambda function, the values inside the value function seem to differ.
If I try to explicitly pass the correct values into the lambda function environment, I get the following (expected) error:
Resource handler returned message: "Lambda was unable to configure your environment variables because the environment variables you have provided contains reserved keys that are currently not supported for modification. Reserved keys used in this request: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
Could someone explain how I could possibly pass the correct access key and id to my lambda function?Akos
08/06/2021, 10:45 AMAkos
08/06/2021, 10:46 AMFazi
08/06/2021, 10:53 AMAkos
08/06/2021, 11:08 AMgrant
method that you can use.
For example with DynamoDB:
sstTable.dynamodbTable.grantReadData(lambda);
sstTable.dynamodbTable.grantReadWriteData(lambda);
Where sstTable is the SST Table construct: https://docs.serverless-stack.com/constructs/TableAkos
08/06/2021, 11:10 AMlambda.addToRolePolicy(
new iam.PolicyStatement({
sid: 'MyDescribeEventsPermission',
effect: iam.Effect.ALLOW,
actions: ['events:DescribeEventBus'],
resources: [
cdk.Fn.sub('arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/*'),
],
})
);
Fazi
08/06/2021, 11:11 AMFazi
08/06/2021, 11:12 AMmyLambdaFunction.attachPermissions(['ssm'])
Would this work? I tried following the docs here: https://docs.serverless-stack.com/design-principles#attaching-permissionsAkos
08/06/2021, 11:15 AMAkos
08/06/2021, 11:15 AMgrantRead
on it: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ssm.StringParameter.html#grantwbrreadgranteeAkos
08/06/2021, 11:16 AMmyLambdaFunction.attachPermissions(['ssm'])
will work 👍 Give it a try!Fazi
08/06/2021, 11:16 AMFrank
Frank
permissions
when defining the Function:
new sst.Function(this, "MyFn", {
handler: "...",
permissions: ["ssm"],
});
or to all functions in ie. an Api inside defaultFunctionProps
Fazi
08/09/2021, 10:06 AM