CloudFormation 业余爱好者在这里。一直在网上查找,但找不到任何关于在我的 RDS 实例通过 CloudFormation 建立后我将如何创建表的参考资料。是否可以指定一个 Lambda 来启动和创建所有表,或者指定一个要应用的 SQL 文件?这方面的标准模式是什么?
amazon-web-services amazon-rds aws-cloudformation aws-lambda
我正在创建一个完全无服务器的解决方案,它也将创建一个 s3 存储桶和 CloudFront。使用来自 bitbucket 管道的云形成模板
我还想为 CloudFront 创建 invalidate。
1)是否有可能在云形成中创建失效?
2)如果不是,那么我怎样才能从我的云形成中获取分布 ID,然后使用 aws cli 创建失效
CFDistribution:
Type: 'AWS::CloudFront::Distribution'
DependsOn: UIBucket
Properties:
DistributionConfig:
Aliases:
- !Sub "${AppSubDomain}.${SSMDomain}"
Origins:
- DomainName: !GetAtt UIBucket.DomainName
Id: S3BucketOrigin
S3OriginConfig:
OriginAccessIdentity: !Join
- ''
- - 'origin-access-identity/cloudfront/'
- !Ref CFOriginAccessIdentity
Comment: !Sub 'CloudFront origin for ${AppSubDomain}.${SSMDomain}'
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
- OPTIONS
TargetOriginId: S3BucketOrigin
ForwardedValues:
QueryString: 'false'
Cookies:
Forward: none
ViewerProtocolPolicy: redirect-to-https
DefaultRootObject: index.html
Enabled: 'true'
HttpVersion: http2
PriceClass: PriceClass_All
ViewerCertificate:
AcmCertificateArn: !Ref …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的 cdk 项目:
import * as cdk from '@aws-cdk/core';
import { TestStack } from '../lib/test-stack';
const app = new cdk.App();
new TestStack(app, 'TestStack');
Run Code Online (Sandbox Code Playgroud)
我可以使用 cdk deploy 轻松部署堆栈,并且堆栈的名称在 AWS 上为“TestStack”。到目前为止,一切都很好。但是我想控制cloudformation中堆栈的名称。有什么方法可以 fdo cdk 部署并更改 AWS 中堆栈的默认名称吗?
像 cdk deploy --stack-name SomeName 这样的东西?((堆栈名称是一个组成的命令))
我想知道这一点,因为我希望能够构建一个部署系统,该系统可以从单个 cdk 项目构建多个堆栈。根据输入参数,每个堆栈都会略有不同。就像是
cdk deploy --stackName Stack1 --parameters parameters1
cdk deploy --stackName Stack2 --parameters parameters2
cdk deploy --stackName Stack3 --parameters parameters3
Run Code Online (Sandbox Code Playgroud)
我最终将在 AWS 中同时拥有 Stack1、Stack2 和 Stack3。
app.synth()AWS CDK 应用程序中该行的用途是什么?例如,可以在第 29 行看到:
https: //github.com/aws-samples/aws-cdk-examples/blob/master/typescript/ecs/fargate-application-load-balanced-service/index.ts
我查看了 CDK 文档,但找不到该函数的实际用途。据我了解,该应用程序是在cdk deploy或上自动合成的cdk synth。我还采用了上面链接的存储库中显示的示例,注释掉该app.synth()行,部署它,它似乎按预期工作。因此我想知道当谈到 app.synth() 的目的时我是否遗漏了一些东西
javascript amazon-web-services aws-cloudformation typescript aws-cdk
我有一个参数“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