我使用无服务器框架来使用以下 CloudFormation 配置创建 Cognito 用户池:
Resources:
CognitoUserPool:
Type: AWS::Cognito::UserPool
Properties:
# Generate a name based on the stage
UserPoolName: ${opt:stage}-user-pool
# Set email as an alias
UsernameAttributes:
- email
AutoVerifiedAttributes:
- email
MfaConfiguration: OFF
EmailVerificationMessage: 'message here'
EmailVerificationSubject: 'subject here'
Policies:
PasswordPolicy:
MinimumLength: 6
RequireLowercase: true
RequireNumbers: false
RequireSymbols: true
RequireUppercase: true
Schema:
- AttributeDataType: String
DeveloperOnlyAttribute: false
Mutable: true
Name: address
Required: true
- AttributeDataType: String
DeveloperOnlyAttribute: false
Mutable: true
Name: email
Required: true
- AttributeDataType: String
DeveloperOnlyAttribute: false …Run Code Online (Sandbox Code Playgroud) amazon-web-services amazon-cognito serverless-framework serverless-architecture aws-serverless
目前,我正在将 AWS 参数存储值作为环境变量访问。它在 serverless yml 中定义如下:
environment:
XYZ_CREDS: ${ssm:xyzCreds}
Run Code Online (Sandbox Code Playgroud)
在代码中,我像这样访问它,因此process.env.XYZ_CREDS
我需要将此值移至 AWS 秘密管理器并以相同的方式访问 xyzCreds。
基于我尝试过的无服务器文档-
custom:
xyzsecret: ${ssm:/aws/reference/secretsmanager/XYZ_CREDS_SECRET_MANAGERa~true}
environment:
XYZ_CREDS: ${self:custom.xyzsecret}}
Run Code Online (Sandbox Code Playgroud)
但这不起作用。请帮忙!
我想测试 serverless.yaml 文件中变量的解析,例如,一些来自命令行,一些来自文件,另一些来自 s3。
例如
environment
whitelist: ${file(config/forwardproxy.sit.yaml):Common.defaultWhitelist}
Run Code Online (Sandbox Code Playgroud)
我想通过试运行进行部署。--nodeploy 选项似乎仅适用于 azure 提供商。
AWS 提供商有办法做到这一点吗?
我正在使用无服务器框架来部署 AWS 资源(用户池、身份池、Dynamo 表)。我知道一旦创建了用户池(以及类似的 Dynamo 索引),您就不能对其进行更改。我想知道更新这些类型的资源而不删除用户/数据的最佳实践是什么?值得庆幸的是,无服务器在部署时发现了问题
不允许更新属性 - UserPoolName
但我听说有人因不小心更新用户池而删除用户。
有什么建议么?
amazon-web-services amazon-cognito serverless-framework aws-userpools
我目前正在使用该serverless-s3-sync插件将本地目录同步到 S3 存储桶中。
我的代码如下所示serverless.yml:
custom:
s3Sync:
- bucketName: mydestintationBucket
localDir: .
acl: public-read
Run Code Online (Sandbox Code Playgroud)
我的问题是我不想将整个目录同步到 S3 存储桶。有没有办法只定义特定的文件夹/文件以同步到S3,或者有更好/其他的方法来做到这一点(例如另一个插件)?
编辑:刚刚找到这个https://github.com/serverless-operations/serverless-step-functions/issues/209基本上就是这个例子,但我不想对 ARN 进行硬编码,而是想使用输入变量(如果有意义的话)。
这是上下文:
使用 Serverless 的错误目标,错误负载会发送到 SQS,SQS 会触发 lambda,启动状态机来执行重试。
例如,如果 Lambda A 失败,该故障将发送到 SQS -> Lambda B,这会触发状态机重试 Lambda A。
我在 Serverless.yml 中定义我的状态机,如下所示(这是我迄今为止一直在尝试的):
stepFunctions:
stateMachines:
MyStateMachine:
name: RetryLambdaMachine
definition:
Comment: Example to test retries
StartAt: StepOne
States:
StepOne:
Type: Task
Resource: arn:aws:states:::lambda:invoke
Parameters:
- FunctionName.$: $$.lambdaArn
#### ^^ This is where I need Lambda A to be referenced ####
Retry:
- ErrorEquals:
- States.ALL
MaxAttempts: 2
Catch:
- ErrorEquals: ["States.ALL"]
Next: CatchAllFallback
End: true
CatchAllFallback:
Type: Task
Resource: …Run Code Online (Sandbox Code Playgroud) 我有一个serverless.yml看起来像这样的
service: my-service
provider:
name: aws
runtime: python3.7
versionFunctions: false
environment:
ACCOUNT_ID: "${file(./serverless.env.yml):${self:provider.stage}.account_id}"
ANOTHER_VARIABLE: "some text ${ACCOUNT_ID} some other text"
Run Code Online (Sandbox Code Playgroud)
这里,我想引用一下现有的ACCOUNT_ID环境ANOTHER_VARIABLE。不起作用${ACCOUNT_ID}。我还尝试查看无服务器文档,但找不到与之相关的任何内容。
environment-variables python-3.x serverless-framework aws-serverless
我使用的是无服务器框架版本 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
我正在用来serverless打包nodejs应用程序。yarn workspace我在我的项目中使用。
- common
- projectA
- projectB
Run Code Online (Sandbox Code Playgroud)
和正在使用由 管理的projectA模块。它在内部创建一个链接。但是当我用 打包应用程序时,它不包含链接。我怎样才能让它打包符号链接?projectBcommonyarn workspacenode_modules/common -> ../commonsls deploynode_modules/common
sls离线命令卡在“离线:启动离线SQS:local/us-east-1”。
"serverless-offline": "^6.8.0",
"serverless-offline-sqs": "4.0.0", // and the all newest
Run Code Online (Sandbox Code Playgroud)
serverless-offline-sqs:
skipCacheInvalidation: false
autoCreate: true
endpoint: http://0.0.0.0:9324
region: ${self:provider.region}
accessKeyId: root
secretAccessKey: root
Run Code Online (Sandbox Code Playgroud)
serverless-offline 和 serverless-offline-sqs 的最新工作版本是什么?
amazon-sqs aws-lambda serverless-framework serverless-offline
aws-lambda ×3
amazon-s3 ×1
amazon-sqs ×1
node.js ×1
python-3.x ×1
serverless ×1
serverless-application-model ×1
yarnpkg ×1