这让我发疯,无论我尝试什么,在创建堆栈时总是出现以下错误:
*The parameter groupName cannot be used with the parameter subnet*
Run Code Online (Sandbox Code Playgroud)
我有三重检查的安全组,子网在同一个 VPC 中。任何建议都会很棒,谢谢
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Microsoft SQL 2012 R2 Test Application Stack",
"Parameters" : {
"pInstanceName" : {
"Description" : "Instance name (up to 15 characters)",
"Type" : "String",
"MinLength" : "1",
"MaxLength" : "15",
"AllowedPattern" : "[a-zA-Z0-9]+",
"Default" : "aws2xxxxxxxxxxx"
},
"pInstanceType" : {
"Description" : "EC2 instance type",
"Type" : "String",
"AllowedValues" : [ "t1.micro", "t2.micro", "t2.small", "t2.medium", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", …Run Code Online (Sandbox Code Playgroud) 我有一个 cloudformation 模板。
它应该创建一个 EC2 实例,更改管理员密码并重命名服务器。
我将几个参数传递给堆栈模板。当我运行它时,它给出“模板格式错误:每个映射成员类型必须是一个映射”。
我确保我在模板中提到的任何内容都在“映射”部分中。不知道为什么我收到这个错误。
任何建议都非常有帮助。
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"LocalAdminPassword" :
{
"Type": "String",
"NoEcho" : "true",
"Description": "Password for the local server administrator account."
}
},
"Mappings": {
"EnvironmentTypeName" :
{
"PlatformName" : {"Dev" : "D", "Test" : "T", "Prod" : "P"}
},
"QRMEnvironmentType" :
{
"Description" : "QRM Dev, test, or Prod Platform",
"Type" : "String",
"AllowedValues" : ["Dev", "Test", "Prod"],
"Default" : "Dev",
"ConstraintDescription" : "must be either Dev, test, or Prod" …Run Code Online (Sandbox Code Playgroud) 使用 Cloudformation 创建新的 KMS 密钥时,我在“状态原因”列中看到此消息:
没有 IAM 权限来处理 AWS::KMS::Key 资源上的标签
cloudformation 堆栈似乎已正确创建,但我想知道如何防止显示此消息?
我正在使用以下 Cloudformation 模板来创建 KMS 密钥:
AWSTemplateFormatVersion: "2010-09-09"
Description: "KMS key"
Outputs:
KeyArn:
Value: !Sub "${KmsKey.Arn}"
Resources:
KmsKey:
Properties:
Description: "KMS key"
Enabled: true
EnableKeyRotation: false
KeyPolicy:
Version: "2012-10-17"
Statement:
- Sid: "Enable IAM User Permissions"
Effect: "Allow"
Principal:
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
Action: "kms:*"
Resource: "*"
Type: "AWS::KMS::Key"
KmsKeyAlias:
Properties:
AliasName: "alias/KmsKey"
TargetKeyId: !Ref "KmsKey"
Type: "AWS::KMS::Alias"
Run Code Online (Sandbox Code Playgroud)
我用来创建资源的角色允许以下操作:
- Action:
- kms:Create*
- kms:List*
Effect: "Allow"
Resource: "*"
- …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-cloudformation amazon-iam amazon-kms
我正在为授予跨账户只读访问权限的 IAM 角色开发 Cloudformation 模板。它也使用托管策略进行只读访问。到目前为止,我已经解决了几个错误,但是现在当我尝试验证模板时出现“模板中不允许使用‘空’值”错误。我认为这是一个空间或语法问题,但我不能确定,因为这是我第一次从头开始创建 cloudformation 模板并使用 YAML。
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS CloudFormation template IAM Role for New Relic to have read access to AWS account
Resources:
NewRelicInfrastructure-IntegrationsRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
Effect: Allow
Principal:
AWS: 11111111
Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId: '11111'
Path: '/'
ManagedPolicyArns: arn:aws:iam::aws:policy/ReadOnlyAccess
RoleName: NewRelicInfrastructure-Integrations2
Run Code Online (Sandbox Code Playgroud) 嗨,我已按照此说明尝试使用 Cloudfront 和 lambda@edge 调整图像大小。当我尝试测试调整大小的图像时,我不断收到以下错误消息:
与 CloudFront 分配关联的 Lambda 函数无效或没有所需的权限。
于是查了一下开头提到的那篇文章提供的云形成创建的lambda函数,发现里面没有触发器。
我尝试手动设置它,但收到以下错误消息:
CloudFront 事件不能与 $LATEST 或别名关联。选择操作以发布新版本的函数,然后重试关联。
我按照错误消息中的说明进行操作;发布,并将 Cloudfront 添加为触发器,但似乎无法应用它。它仍在运行没有 Cloudfront 作为触发器的那个。
有什么方法可以将 Cloudfront 设置为触发器并使其正常工作?
amazon-web-services amazon-cloudfront aws-cloudformation aws-lambda aws-lambda-edge
我尝试使用以下模板创建一个 EC2 实例:
Parameters:
KeyName:
Default: TestKeyPair
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
Type: AWS::EC2::KeyPair::KeyName
Resources:
Dev:
Properties:
ImageId: ami-4e79ed36
InstanceType: t2.micro
KeyName: !Ref 'KeyName'
SecurityGroups:
- !Ref 'SSH'
Type: AWS::EC2::Instance
Run Code Online (Sandbox Code Playgroud)
但我得到:
An error occurred (ValidationError) when calling the CreateChangeSet operation: Template format error: Unresolved resource dependencies [SSH] in the Resources block of the template
Run Code Online (Sandbox Code Playgroud)
我无法理解模板中有什么问题,因为名为“SSH”的安全组已经存在:
$ aws ec2 describe-security-groups --group-names SSH
....
"IpPermissions": [
{
"ToPort": 22,
"IpRanges": [
{
"CidrIp": …Run Code Online (Sandbox Code Playgroud) 是否可以在 cloudformation 模板中静态指定 AWS::StackName?还是只能在运行模板时将其指定为参数?
据我了解,这个值只能通过伪参数读取,不能设置:
使用 CloudFormation 创建 S3 存储桶时遇到此问题。我收到一个 400 Bad 的请求。如果有人可以提供帮助,将不胜感激。
aws cloudformation deploy --profile DEV --stack-name testBucket --template-file create_bucket.yml --region us-east-1 --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM --parameter-overrides BucketName=myBucket
模板:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
BucketName:
Description: Provisioned read throughput for each table
Type: String
Resources:
MYBUCKET:
Type: AWS::S3::Bucket
Properties:
BucketName: ${BucketName}
MYBUCKETPOLICY:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref MYBUCKET
PolicyDocument:
Id: ReportPolicy
Version: "2012-10-17"
Statement:
- Sid: ReportBucketPolicyDoc
Effect: Allow
Action: "s3:*"
Principal:
AWS: !Join ['', ["arn:aws:iam::", !Ref "AWS::AccountId", ":root"]]
Resource: !Join ['', ['arn:aws:s3:::', !Ref MYBUCKET, '/*']] …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 cloudformation (yaml) 中定义角色和用户之间的信任关系策略文档。
为了在角色的 中指定用户的 ARN AssumeRolePolicyDocument,我想从实际的 cloudformation 资源中引用 ARN,而不必构造 ARN 字符串。
但是,它不起作用。当我使用 时!Ref rUser,在创建 cloudformation 堆栈时出现错误“策略中的无效主体”。
当我只是将 ARN 字符串粘贴为值时,它就起作用了。是因为!Ref rUser返回用户对象类型并且不计算为字符串吗?如果是这样,我如何从资源中引用 ARN?
代码:
rUser:
Type: "AWS::IAM::User"
Properties:
UserName: "my_user"
rRole:
DependsOn: rRole
Type: "AWS::IAM::Role"
Properties:
RoleName: "my_role"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
AWS:
# this does not work, gives error "Invalid Principal in policy"
- !Ref rUser
# this does work (just hard coding the ARN string):
# - "arn:aws:iam::111111111111:user/my_user"
Action: …Run Code Online (Sandbox Code Playgroud) 当您在同一区域内运行多个 CloudFormation 堆栈时,您可以使用CloudFormation 输出跨堆栈共享引用
但是,正如该文档所强调的那样,输出不能用于跨区域引用。
您不能跨区域创建跨堆栈引用。您可以使用内部函数 Fn::ImportValue 仅导入已在同一区域内导出的值。
您如何在 CloudFormation 中跨区域引用值?
作为要遵循的示例,我有一个Route 53 托管区域部署在us-east-1. 但是,我有一个后端,us-west-2因为我想创建一个经过DNS 验证的 ACM 证书,该证书需要对托管区域的引用,以便能够创建适当的 CNAME 来证明所有权。
我将如何引用us-east-1从内部创建的托管区域 ID us-west-2?
amazon-web-services aws-cloudformation aws-cloudformation-custom-resource
amazon-iam ×3
amazon-ec2 ×1
amazon-kms ×1
amazon-s3 ×1
aws-cloudformation-custom-resource ×1
aws-lambda ×1
json ×1
yaml ×1