(Optional) inspect and test your infrastructure (original) (raw)

This topic shows how to view your infrastructure components and test your Lambda function.

To see the result of your stack after you run sam deploy
  1. Open the AWS CloudFormation console athttps://console.aws.amazon.com/cloudformation.
  2. In the navigation pane, choose Stacks. Themy-date-time-app stack appears at the top.
  3. Choose the Events tab to see which events are complete. You can view the events while the stack creation is in progress. When creation of the stack is complete, you can see all stack creation events.
  4. With your stack selected, choose Resources. In theType column, you can see your Lambda functions,myDateTimeFunction, CodeDeployHook_beforeAllowTraffic, andCodeDeployHook_afterAllowTraffic. The Physical ID column of each of your Lambda functions contains a link to view the functions in the Lambda console.
Note

The name of the myDateTimeFunction Lambda function is prepended with the name of the AWS CloudFormation stack and has an identifier added to it, so it looks likemy-date-time-app-myDateTimeFunction-123456ABCDEF. 5. Open the CodeDeploy console athttps://console.aws.amazon.com/codedeploy/. 6. In the navigation pane, expand Deploy, and then chooseApplications. 7. You should see a new CodeDeploy application created by AWS CloudFormation with a name that starts with my-date-time-app-ServerlessDeploymentApplication. Choose this application. 8. You should see a deployment group with a name that starts withmy-date-time-app-myDateTimeFunctionDeploymentGroup. Choose this deployment group.
Under Deployment configuration, you should seeCodeDeployDefault.LambdaLinear10PercentEvery1Minute.

(Optional) to test your function (console)
  1. Open the AWS Lambda console athttps://console.aws.amazon.com/lambda/.
  2. From the navigation pane, choose yourmy-date-time-app-myDateTimeFunction function. In the console, its name contains an identifier, so it looks likemy-date-time-app-myDateTimeFunction-123456ABCDEF.
  3. Choose Test.
  4. In Event name, enter a name for your test event.
  5. Enter the following for your test event, and then chooseCreate.
{  
  "option": "date",  
  "period": "today"  
}  
  1. Choose Test. You should see only your test event in the list of test events.
    For Execution result, you should seesucceeded.
  2. Under Execution result, expand Details to see the results. You should see the current month, day, and year.
(Optional) to test your function (AWS CLI)
  1. Locate the ARN of your Lambda function. It appears at the top of the Lambda console when you are viewing your function.
  2. Run the following command. Replace your-function-arn with the function ARN.
aws lambda invoke \  
--function your-function-arn \  
--cli-binary-format raw-in-base64-out \  
--payload "{\"option\": \"date\", \"period\": \"today\"}" out.txt  
  1. Open out.txt to confirm the result contains the current month, day, and year.

Deploy the AWS SAM application

Step 2: Update the Lambda function

Did this page help you? - Yes

Thanks for letting us know we're doing a good job!

If you've got a moment, please tell us what we did right so we can do more of it.

Did this page help you? - No

Thanks for letting us know this page needs work. We're sorry we let you down.

If you've got a moment, please tell us how we can make the documentation better.