【发布时间】:2019-09-02 00:37:20
【问题描述】:
我们希望使用特定标签标记 cloudformation 堆栈的每个资源(出于计费和财务原因)。这包括安装在 (/dev/sda1) 下的主分区上使用的主存储。
这就是我们所拥有的:
---
AWSTemplateFormatVersion: '2010-09-09'
Description: The Name
Parameters:
InstanceType:
Description: EC2 instance type
Type: String
Default: t3.small
AllowedValues:
- t3.nano
- ...
InstanceName:
Description: Name Tag
Type: String
Resources:
TheECCInstance:
Type: AWS::EC2::Instance
Properties:
KeyName: jenkins
ImageId: !FindInMap [RegionMap, !Ref 'AWS::Region', AMI]
InstanceType:
Ref: InstanceType
SubnetId: subnet-0e9c7d7c2711aaf9e
BlockDeviceMappings:
- DeviceName: "/dev/sda1"
Ebs:
VolumeSize:
Ref: EBSBlockSize
VolumeType: gp2
Tags:
- Key: Name
Value:
Ref: InstanceName
- Key: Type
Value: TheType
Mappings:
RegionMap:
'ap-northeast-3':
NAME: ap-northeast-3b
AMI: 'ami-05e896b95030bd37c'
'sa-east-1':
NAME: sa-east-1b
AMI: 'ami-03c6239555bb12112'
'eu-west-1':
NAME: eu-west-1b
AMI: 'ami-00035f41c82244dab'
...
Outputs:
...
我不介意使用类似的东西:
RootVolume:
Type: AWS::EC2::Volume // Or Something in that direction (EFS / EBS / whatever)
Properties:
Size:
Ref: EBSBlockSize
VolumeType: gp2
AvailabilityZone: !FindInMap [RegionMap, !Ref 'AWS::Region', NAME]
Tags:
- Key: Type
Value: TheType
并安装它。将其作为主分区连接似乎是不可能的。可以是 AWS::EC2::Volume、AWS::EFS 等。如有任何帮助,我们将不胜感激。我们目前创建实例,然后在创建堆栈后进行标记。但这似乎有些脆弱,应该有一种更简单的方法来做到这一点......
【问题讨论】:
-
为了便于阅读,对上面的代码进行了简化和修改。
-
AFAIK 您可以使用 BlockDeviceMappings 来执行此操作。不过,您确实需要单独定义 EBS。
-
谢谢@DroidX86。但问题一般不在于设备。它是根设备。我可以生成临时文件,但“/dev/sda1”似乎是个问题......
-
这是为什么呢?有什么错误吗?
-
不同的错误。我会在收集问题后尝试更新问题。
标签: amazon-web-services configuration tags config amazon-cloudformation