4ka*_*set 5 environment-variables go amazon-sqs aws-lambda
我正在尝试使用 cloudformation 开发无服务器应用程序。我需要一个 go lambda 函数来在 SQS 中发送消息。要发送这些消息,我需要一个队列 URL。我应该将此 URL 存储在我的 lambda 函数的环境变量中。
但是当我在本地运行它时sam local start-api
,我的变量是空的。当我部署它时,它可以工作,但我无法在本地测试它。
这是我的模板.yaml:
APIGetFunction:
Type: 'AWS::Serverless::Function'
Properties:
Handler: service_get_person
Runtime: go1.x
CodeUri: ./src/person/service/get_person
Description: 'Get a person'
MemorySize: 128
Timeout: 30
Role: !GetAtt LambdaExecutionRole.Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /person
Method: get
Environment:
Variables:
QueueUrl: !Ref MyQueue
REGION: eu-west-3
MyQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: test_queue
DelaySeconds: 0
VisibilityTimeout: 120
Run Code Online (Sandbox Code Playgroud)
我正在使用os.Getenv("QueueUrl")
我的变量。
你们中有人有解决这个问题的方法吗?
归档时间: |
|
查看次数: |
1182 次 |
最近记录: |