我有一个 .NET 解决方案,它使用 SAM 模板生成 cloudformation 来部署堆栈。我期望部署 - 一旦完成 - 至少在其中一种方法上需要 API Key = true。但是部署后,创建了密钥和使用计划,但在控制台中所需的 api 密钥仍然设置为 false?
见下文:
我的 SAM 模板:
"ServerlessRestApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Description":"This is a placeholder for the description of this web api",
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
}
},
"x-amazon-apigateway-api-key-source": "HEADER",
"paths": {
"datagw/general/table/get/{tableid}": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetTableResponse.Arn}/invocations"
}
},
"responses": {}
},
"security":[
{
"api_key":[]
}
]},
"securityDefinitions":{ …Run Code Online (Sandbox Code Playgroud) aws-cloudformation swagger aws-api-gateway serverless-application-model
我使用的是无服务器框架版本 2.11.0
尝试部署时,它抛出无服务器错误:
Configuration error at 'provider.logRetentionInDays': should be equal to one of the allowed values
Run Code Online (Sandbox Code Playgroud)
但它没有显示任何允许的值。同样在我的例子中,我给出的值为 90(整数)。我做错了什么吗?
serverless-framework serverless-architecture serverless aws-serverless serverless-application-model
是否有类似于Lambda 函数权限的DynamoDBReadPolicy托管策略?ssm:GetParameter*我正在使用 aws-sam-cli 并尝试遵循此操作,但是当我尝试在使用时获取参数时sam local start-api,出现以下错误:
InvalidAction: The action or operation requested is invalid. Verify that the action is typed correctly.
这是我尝试获取参数的片段:
const ssm = new AWS.SSM();
const param = {
Name: "param1",
WithDecryption: true
};
const secret = await ssm.getParameter(param).promise();
Run Code Online (Sandbox Code Playgroud)
相关模板部分如下。谢谢!
KeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: 'param1Key'
TargetKeyId: !Ref Key
Key:
Type: AWS::KMS::Key
Properties:
KeyPolicy:
Id: default
Statement:
- Effect: Allow
Principal:
AWS: !Sub arn:aws:iam::${AWS::AccountId}:root
Action:
- 'kms:Create*'
- 'kms:Encrypt'
- …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-lambda aws-sam-cli aws-serverless serverless-application-model
我正在使用 SAM(无服务器应用程序模型)并为 dynamo 的 lambda 函数创建策略。默认情况下,AmazonDynamoDBFullAccess在那里,但我想为 lambda 函数提供DynamoDBCrudPolicy,其中使用了多个表。
在 aws sam docs 中有一张桌子的政策,不超过一张
Policies:
# Give just CRUD permissions to one table
- DynamoDBCrudPolicy:
TableName: !Ref MyTable
Run Code Online (Sandbox Code Playgroud)
这是一张桌子的 CRUD 政策,我想要一张以上的桌子。
amazon-web-services aws-cloudformation amazon-dynamodb serverless-application-model
在SAM 文档中,可以部署您自己的 lambda 端点并使用 Python SDK 调用它。
您只需启动本地 lambda 端点sam local start-lambda,然后继续
# USING AWS SDK
-------------
#You can also use the AWS SDK in your automated tests to invoke your functions programatically.
#Here is a Python example:
self.lambda_client = boto3.client('lambda',
endpoint_url="http://127.0.0.1:3001",
use_ssl=False,
verify=False,
config=Config(signature_version=UNSIGNED,
read_timeout=0,
retries={'max_attempts': 0}))
self.lambda_client.invoke(FunctionName="HelloWorldFunction")
Run Code Online (Sandbox Code Playgroud)
我现在的问题是,我怎样才能用 Javascript SDK 做同样的事情?我总是收到有关缺少区域、未找到主机和不受支持的参数的不同错误。你有办法帮我解决吗?
javascript amazon-web-services node.js aws-lambda serverless-application-model
"The event is not supported for notifications (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: CF3108325F3C9B60; S3 Extended Request ID: wcWzRXUu7YJn/BVnPDtOx7yBHllhIPELEwsTweqVcfwLw1hkR2iDiSmQbxeL3Hrtp7Kv58ujS2s=; Proxy: null)"
Run Code Online (Sandbox Code Playgroud)
请参阅以下来自 AWS Mgm 控制台的 CloudFormation 事件:
下面是我的 AWS SAMtemplate.yaml文件:
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function.
Resources:
olatexOrdersInputDirectory:
Type: 'AWS::S3::Bucket'
olatexXlsxOrderLoader:
Type: 'AWS::Serverless::Function'
Properties:
Handler: olatexXlsxOrderLoader/index.handler
Runtime: nodejs12.x
Description: ''
MemorySize: 128
Timeout: 15
Policies:
- AWSLambdaBasicExecutionRole
- …Run Code Online (Sandbox Code Playgroud) amazon-s3 amazon-web-services aws-cloudformation serverless-application-model
我遇到一个问题,我试图开始mvn install工作,以便sam build使用 Docker 进行本地调用,但由于以下错误,它一直失败:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project my-project: The packaging for this project did not assign a file to the build artifact -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
StackOverflow 上有许多关于“此项目的打包未将文件分配给构建工件”的问题和解决方案的不同迭代,但它们似乎都没有解决我的问题。
例如,我可以执行 amvn jar:jar install:install并且它可以正常工作,但我无法像 SAM 构建中那样指定目标,因此这不是一个正确的解决方案 - 我需要mvn install工作。我尝试了多种删除 .m2 文件夹的方法,但没有任何作用。我也可以更改maven-install-plugin的版本,但无济于事。我可以在 maven-install-plugin 中指定该文件,如果路径正确,它不会看到它,但如果不正确,它会说它不存在。
似乎没有什么可以解决这个问题,所以我需要找到一个真正的解决方案。
这是我的 pom.xml:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project my-project: The packaging for this project did not assign a file to the …Run Code Online (Sandbox Code Playgroud) java amazon-web-services maven aws-lambda serverless-application-model
serverless-application-model ×7
aws-lambda ×3
amazon-s3 ×1
aws-sam-cli ×1
java ×1
javascript ×1
maven ×1
node.js ×1
serverless ×1
swagger ×1