I am new to AWS SSM, my requirement is I have a Lambda function created for which I have to invoke this lambda using an SSM Document is it achievable? If so how please explain.
Thanks in Advance
You cannot directly invoke Lambda from SSM. However, you can configure the SSM to write logs to AWS Cloudwatch. From Cloudwatch it is possible to invoke a Lambda function in response to logs.
Related
Can we invoke an AWS Lambda function from EC2 instances?
I have tried AWS Lambda invoking another Lambda, but not sure if we do can invoke from EC2 instance.
Yes.
You can invoke the Lambda from EC2 instance just like from any other machine.
Just use the boto3 call invoke() or use the cli to invoke it
In the AWS Lambda management console you can have test events associated with a function.
Is it possible to configure the test events when deploying the Lambda function using the AWS CDK such that the test events are ready to use when someone later views the function in the management console?
That is not possible at the moment as CloudFormation itself does not support this (see this answer). You can, as mentioned in the linked post, use a CloudFormation CustomResource to prepare the invocation.
Another option is to create a output that prepares a cli command with payload. So that you can just copy past the generated call aws lambda invoke --function-name {PopulateFromCDK} --payload '{"key": "value"}'
I want to have a cloud formation template to list all lambda functions for a particular region. I don't need to write a lambda code using list-function and call it inside my CFT.
I tried incorporating CLI command inside CFT but it didn't work
There is no way to directly add a aws cli command in a cloudformation template. Either you will have to create a EC2 instance and then run the CLI command in the user data or create a lambda backed custom resource to do it.
Both will complicate the simple CLI command.
aws lambda list-functions --region eu-west-1
CFN is just an orchestration tool. It cannot compute on itself.
Instead we can use a simple lambda python script and invoke the same in the CFT
import boto3
#Create an lambda client
client = boto3.client(
"lambda"
)
response = client.list_functions(
MasterRegion='string',
FunctionVersion='ALL',
Marker='string',
MaxItems=123
)
print(response)
I am new with the aws api and system in general and im currently working with three parts of aws;
Connect
Lambda
Lex
I am trying to get connect to call a lambda function with a simple parameter, but i am getting this error in cloudwatch;
cloudwatch
I tried a google search but it seems that everyone thinks it is IAM related, even though i have a role with the right permissions;
lambda role
and detailed;
enter image description here
it looks like the trigger is already there
Does anyone know why i can't get to invoke my lambda function? Permissions should be fine, i think...
Thank you
You need to configure a "Trigger Policy" which allows AWS Connect to invoke your AWS Lambda.
You can configure it through the AWS CLI:
aws lambda add-permission --function-name function:my-lambda-function --statement-id 1 \
--principal connect.amazonaws.com --action lambda:InvokeFunction --source-account 123456789012 \
--source-arn arn:aws:connect:us-east-1:123456789012:instance/def1a4fc-ac9d-11e6-b582-06a0be38cccf \
This command uses the following input:
The name of the Lambda function (for example, my-lambda-function)
The ARN of a Amazon Connect instance (for example,
arn:aws:connect:us-east-1:123456789012:instance/def1a4fc-ac9d-11e6-b582-example) - To find the ARN for your instance, open the Amazon Connect console,
and then choose the Instance Alias to open the Overview page.
The AWS account ID for the Lambda function (for example, 123456789012)
For more details please check the Documentation: Using AWS Lambda Functions with Amazon Connect
I created simple Lambda function for processing Amazon SES incoming email.
Function works, testing it with SES data works from Lambda editing panel.
When trying to create SES email receiving rule always getting identical errors:
Invalid Lambda function:
arn:aws:lambda:region:userid:function:functionname
(Request ID: requestid)
Tried to add roles for this lambda via command line:
aws lambda add-permission
--function-name arn:aws:lambda:region:userid:function:functionname
--statement-id=GiveSESPermissionToInvokeFunction
--principal=ses.amazonaws.com
--action=lambda:InvokeFunction
--source-account=userid
--region "region"
role is added successfully, but it's not helping.
The Lambda function needs to be in the same AWS region as you are configuring the SES rule in.