I have a SAM template that takes parameters in the .yml file, and I want to access the parameter value within the lambda function written in c#
here is the SAM template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Globals:
Function:
Timeout: 60
Runtime: dotnetcore2.1
Parameters:
ApiBaseUri:
Type: String
Default: https://postb.in/1584332032935-8906962152104
Description: The API URL where the received events will be pushed by the lambda function
Resources:
PushUpdates:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./src/PushAPIs/
Handler: Localgov.Microservices::LambPaymentTracker.UpdateHandler::PushBurtonUpdates
Runtime: dotnetcore2.1
Policies: AWSLambdaDynamoDBExecutionRole
Events:
Stream:
Type: DynamoDB
Properties:
Stream: !GetAtt UpdatesTable.StreamArn
BatchSize: 100
StartingPosition: TRIM_HORIZON
The common way of passing cloudformation (or sam) variables to lambda would be through Environment Variables.
In your template you specify the variables using Environment property.
In your code, you then use your programming language specific functionality to read them.