Amazon web services 在SQS中为无服务器启用静态加密
我们在应用程序中使用无服务器框架和微服务(lambda函数)。在serverless.yml文件中,我们列出了部署时需要创建的资源 serverles.yml文件的参考资料部分如下所示:Amazon web services 在SQS中为无服务器启用静态加密,amazon-web-services,encryption,amazon-cloudformation,amazon-sqs,Amazon Web Services,Encryption,Amazon Cloudformation,Amazon Sqs,我们在应用程序中使用无服务器框架和微服务(lambda函数)。在serverless.yml文件中,我们列出了部署时需要创建的资源 serverles.yml文件的参考资料部分如下所示: resources: Resources: GatewayResponse: Type: "AWS::ApiGateway::GatewayResponse" Properties: Re
resources:
Resources:
GatewayResponse:
Type: "AWS::ApiGateway::GatewayResponse"
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: EXPIRED_TOKEN
RestApiId:
Ref: "ApiGatewayRestApi"
StatusCode: "401"
AuthFailureGatewayResponse:
Type: "AWS::ApiGateway::GatewayResponse"
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: UNAUTHORIZED
RestApiId:
Ref: "ApiGatewayRestApi"
StatusCode: "401"
SqsQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: ${opt:stage}-${opt:product}-sqs-queue
VisibilityTimeout: 900
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- SqsDeadLetterQueue
- Arn
maxReceiveCount: 1
SqsDeadLetterQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${opt:stage}-${opt:product}-deadletter-queue
MessageRetentionPeriod: 1209600
如您所见,我们也在那里创建SQS队列资源。最初我们在SQS中没有启用rest加密,但现在需要了
我可以进入AWS控制台,然后从那里手动为我们创建的每个队列启用静态加密,但这将非常繁琐,而且我希望将其包括在serverless.yml创建中,以便从现在开始创建的任何SQS资源都默认启用加密
我想知道我需要向serverless.yml的参考资料部分添加什么。我是否添加CMK(客户主密钥)别名,我是否可以使用默认的CMK别名,或者我是否需要为此生成新的CMK别名。我是否还需要修改引用SQS的其他lambda,以便他们能够访问它
我以前从未这样做过,因此需要详细的帮助
谢谢。要将加密添加到队列中,您必须将其添加到模板中的队列中。如果要使用AWS管理的CMK,id将为
alias/AWS/sqs
(假设两个队列):
将静态加密(无论是KmsMasterKeyId还是AWS管理的CMK)添加到SQS会对其他可能使用这些资源的lambda产生任何影响吗?所以我有其他lambda,我在这里调用上面创建的sqs队列,我需要在那里传递任何东西吗?@codeinprogress我认为它应该是透明的。如果需要,可以在一些伪sqs和lambda函数上检查它well@codeinprogress是的,bucket也有类似的加密设置。它是如何进行的?问题仍然存在?@Marcin,今天将更新serverless.yml,并将在这里回复。我要试着用一个lambda,看看其他使用队列的lambda是否可以调用它。@Marcin,成功了。我的另一个lambda函数能够调用加密的sqs队列。谢谢你的帮助。
resources:
Resources:
GatewayResponse:
Type: "AWS::ApiGateway::GatewayResponse"
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: EXPIRED_TOKEN
RestApiId:
Ref: "ApiGatewayRestApi"
StatusCode: "401"
AuthFailureGatewayResponse:
Type: "AWS::ApiGateway::GatewayResponse"
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: UNAUTHORIZED
RestApiId:
Ref: "ApiGatewayRestApi"
StatusCode: "401"
SqsQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: ${opt:stage}-${opt:product}-sqs-queue
VisibilityTimeout: 900
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- SqsDeadLetterQueue
- Arn
maxReceiveCount: 1
KmsMasterKeyId: alias/aws/sqs
SqsDeadLetterQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${opt:stage}-${opt:product}-deadletter-queue
MessageRetentionPeriod: 1209600
KmsMasterKeyId: alias/aws/sqs