我有一个参数“SecretKey”,我想为其提供一个默认值(http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html),默认值是生成的随机字符串。我已经有一个lambda 函数来生成密钥和一个自定义资源(调用它RandomSecretKey)来获取值。最终,我希望能够在参数部分执行此操作:
"SecretKey": {
...
"Default": { "Fn::GetAtt": ["RandomSecretKey", "Value"] }
}
这个参数会在某处被引用。
但这不起作用,因为 CloudFormation 需要基于错误消息的静态字符串。有没有办法做到这一点?
我正在为无服务器框架编写一个插件,它通过 ARN 引用 DynamoDB Stream。我可以使用手头的信息构建 DynamoDB 表 ARN,但我不知道时间戳部分,这是构建完整流 ARN 所必需的。我无权访问原始 DynamoDB Cloudformation 定义,当我需要引用 Stream ARN 时,这两件事可能会在完全不同的模板中发生。此时我所拥有的只是已创建的 DynamoDB 的 ARN。
有没有办法通过类似于 的变量来引用最新的流 arn:aws:dynamodb:${AWS::Region}::${AWS::AccountId}:table/eventbus-test/stream/${LATEST}?
或者我可以通过无服务器配置或 Cloudformation 模板以另一种方式构建它吗?
amazon-web-services aws-cloudformation amazon-dynamodb serverless-framework amazon-dynamodb-streams
反正我们可以通过动态引用来揭秘经理到AWS启动配置用户数据?
这是我尝试过的代码片段:
"SampleLaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Fn::FindInMap": [
"AWSRegionArch2AMI",
{
"Ref": "AWS::Region"
},
"AMI"
]
},
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash -xe\n",
"yum update -y\n",
"useradd -p <<pwd>>{{resolve:secretsmanager:Credentials:SecretString:userName}}\n",
"\n"
]
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
获取 useradd 时出现错误:无效的用户名 '{{resolve:secretsmanager:Credentials:SecretString:userName}}'
如何将 Secret Manager 秘密值传递给 cloudformation 用户数据?
部署 CloudFormation 堆栈时获取以下信息:
REST API 不包含任何方法(服务:AmazonApiGateway;状态代码:400;错误代码:BadRequestException;请求 ID:d527f56e-a1e1-11e9-a0a4-af7563b2b15a)
该堆栈具有由具有单个资源和方法的 API 触发的单个 Lambda:
FailureReporting:
Type: "AWS::ApiGateway::RestApi"
DependsOn: "MyLambdaFunction"
Properties:
Name: "FailureReporting"
FailOnWarnings: true
FailureReportingDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId:
Ref: "FailureReporting"
Description: "Production environment supporting version-1 of the interface."
StageName: "v1"
Failures:
Type: "AWS::ApiGateway::Resource"
Properties:
RestApiId: !Ref "FailureReporting"
ParentId: !GetAtt ["FailureReporting", "RootResourceId"]
PathPart: "failures"
FailuresMethodGet:
Type: "AWS::ApiGateway::Method"
Properties:
RestApiId: !Ref "FailureReporting"
ResourceId: !Ref "Failures"
HttpMethod: "GET"
AuthorizationType: "NONE"
MethodResponses:
- StatusCode: "200"
Integration:
IntegrationHttpMethod: "POST"
Type: "AWS_PROXY"
IntegrationResponses:
- StatusCode: "200"
Credentials: !GetAtt …Run Code Online (Sandbox Code Playgroud) 我想将我的 SAM 应用程序拆分为多个部分。
我想在根堆栈中创建一个 API ( AWS::Serverless::Api )。
我正在我的子堆栈中创建 lambda 函数,我想在其中提供从根堆栈到 API 事件的 API 引用。
这可行吗?我没有找到任何从根堆栈访问 API 到子堆栈的好例子?
我尝试使用以下模板 -
parenttemplateapi:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:account_id:applications/parent-template
SemanticVersion: 1.0.0
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python2.7
Events:
HelloWorld:
Type: Api
Properties:
Method: get
Path: /hello
RestApiId: !GetAtt parenttemplateapi.Outputs.ServerlessGW-restApiId
Run Code Online (Sandbox Code Playgroud)
当我尝试部署此模板时,出现以下错误 -
错误:无法为堆栈创建变更集:子模板,例如:Water ChangeSetCreateComplete 失败:Water 遇到终端故障状态状态:FAILED。原因:转换 AWS::Serverless-2016-10-31 失败:内部转换失败。
任何指示/建议?
我指的是以下链接 -
此处可以使用来自根堆栈的 API 网关 ID (AWS::ApiGateway::RestApi) 吗?
https://dev.to/grahamcox82/building-a-larger-serverless-application-part-3-modular-monorepos-3mon
这可以使用无服务器框架来实现吗?
amazon-web-services aws-cloudformation aws-api-gateway serverless-framework aws-sam
我一直在为下面的错误而苦苦挣扎。我已经尝试了很多教程和 stackoverflow 答案,但没有一个解决方案可以解决我的问题。
从源“ http://localhost:3000 ”访问 XMLHttpRequest at ' https://xxx '已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:否 'Access-Control-Allow-Origin ' 请求的资源上存在标头。
我正在使用 SAM 无服务器来创建我的 api。
模板.yaml:
Globals:
Function:
Timeout: 10
Api:
Cors:
AllowMethods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
Run Code Online (Sandbox Code Playgroud)
我的 lambda 函数: 我的 GET 响应和 OPTIONS 响应都返回以下标头:
headers: {
"Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'",
"Access-Control-Allow-Origin": "'*'",
"Access-Control-Allow-Methods": "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'"
}
Run Code Online (Sandbox Code Playgroud)
我的 API 使用放大进入我的 ReactJs 应用程序:
API.get(apiName, path, {
headers: {
"Access-Control-Allow-Origin": "*",
// "Access-Control-Allow-Headers": "Content-Type,X-Amz-Date,Authorization,X-Api-Key,x-requested-with",
// "Access-Control-Allow-Methods": "OPTIONS,POST,GET,PUT,DELETE",
// 'Content-Type': 'application/json'
}
})
Run Code Online (Sandbox Code Playgroud)
我已经在我的 template.yaml、我的 lambda 函数和我的 reactJs 项目中尝试了 Access-Control-Allow-Headers、Access-Control-Allow-Methods …
javascript sam aws-cloudformation aws-api-gateway aws-serverless
我在这里有些困惑,想看看是否有人能让我直截了当。
我正在将 Amplify 用于 Vue 应用程序。它调用调用 Lambda 的 API 网关,所有这些都是手动设置的,但我想使用 IaaS 的强大功能并使用 SAM 来完成。
Amplify CLI 包括添加 API/函数的能力,进而创建 CloudFormation 模板和堆栈,这很好。然而,这似乎并没有创建 Amplify 应用程序本身,除了创建一个连接到没有存储库的空应用程序,当然 CLI 只延伸到这么多服务。
我发现可以在 CloudFormation 中配置 Amplify 应用程序。SAM 附带的命令行工具也很有用。设置所有这些的正确方法是什么?
我能否为 Amplify 创建创建一个 SAM 模板,该模板与 Amplify 创建的堆栈配合使用以创建 API/函数,而不是在没有自动生成帮助的情况下手动构建 SAM 模板?然后,如果我稍后添加不支持 Amplify 的服务,我也可以将它们添加到 SAM。
我有时间尝试导航 SAM/CF/CDK/Amplify 哈哈
我是 AWS 的新手,我有一个脚本,我相信它应该创建一个 ECS 集群。
当我运行脚本时,我的堆栈在该CREATE_IN_PROGRESS状态下挂起一个多小时。最终,它失败并进入ROLLBACK_COMPLETE.
当我在 AWS 控制台中的 Cloudformation 中时,我可以转到“事件”并看到我尝试创建的两个服务导致堆栈创建失败。然而,唯一的错误消息是Resource creation timed out waiting for completion。
我已经尝试了此处概述的步骤,即包括进入 CloudTrail,但我不太确定要查找什么,也没有找到任何可以帮助我解决问题的内容。再说一遍,我是 AWS 菜鸟。
我可以采取哪些步骤来获取更详细的错误消息?如何在 AWS 中进行调试?
感谢任何帮助,如果我需要提供更多信息,请告诉我。
amazon-web-services amazon-ecs aws-cloudformation amazon-cloudtrail
我必须部署一个堆栈,我们将其称为一个区域中的父堆栈。需要在另一个区域中部署第二个堆栈(子堆栈)。第二个堆栈(子堆栈)的区域不能包含部署父堆栈的区域。第二个堆栈可以部署在多个区域。
然而,第二个堆栈需要来自第一个堆栈的道具。具体来说,它需要一个 ARN 值。默认区域是us-east-1. 这就是部署父堆栈的地方。
为了解决这个问题我尝试了以下方法
1-第一次尝试:使用 cfnOutput
cfnOutput 我捕获的值cdk.Fn.ImportValue()2-第二次尝试:使用 StackProps
来自 lib/mystack 文件
export interface myStackProps extends cdk.StackProps {
principalKeyArn: string
}
Run Code Online (Sandbox Code Playgroud)
来自 bin/myapp 文件
const app = new cdk.App();
const regions = ["us-east-2"]
const primaryMRKey = new KmsMultiregionPrincipalKey(app, 'KmsMultiregionKeyStack')
for (let region of regions){
const envToDeploy = {region: region, account: "123456789123"}
new KmsReplicaKey(app, …Run Code Online (Sandbox Code Playgroud) 一个团队已经将一个cloudformation模板编写为一个.yml提供一堆资源的文件.
是否可以通过在Terraform中执行来利用此文件?还是必须重写?
我是terraform的新手,刚入门.
如果我使用AWS CLI,我会执行这样的命令,
aws cloudformation create-stack --stack-name my-new-stack --template-body file://mystack.yml --parameters ParameterKey = AmiId
我想在我的terraform配置中包含相当于此命令的内容.
如果有可能,你可以给我一个例子,我真的很感激.
谢谢!
aws-sam ×2
amazon-ecs ×1
amazon-kms ×1
aws-amplify ×1
aws-cdk ×1
javascript ×1
sam ×1
terraform ×1