aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

AWS::EC2::Instance - BlockDeviceMapping-Ebs should expose volume IDs via Fn::GetAtt

Open
#113 0 comments 9 reactions 0 assignees View on GitHub
compute
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

## 1. AWS::EC2::Instance-BlockDeviceMapping-Ebs should expose volume IDs via Fn::GetAtt

## 2. Scope of request

It would be helpful to be able to get the EBS volume IDs (and possibly other properties) for EBS volumes specified via the `BlockDeviceMapping` property, such as to add CloudWatch alarms or build dashboards for root volumes.

## 3. Expected behavior

Samples:
I should be able to use `Fn::GetAtt` to retrieve the volume ID associated with EBS volumes in the `BlockDeviceMapping` property.

There are a few ways to go about this, the simplest may be to expose the volumes indexed in the order they were listed:

```
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"BlockDeviceMappsings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {
"VolumeType": "gp2",
"VolumeSize": { "Ref": "RootVolumeSize" }
}
},
{
"DeviceName": "/dev/sdh",
"Ebs": {
"VolumeType": "gp2",
"VolumeSize": 500
}
}
]
},

"RootVolumeBurstAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
...
"Dimensions": [
{
"Name": "VolumeId",
"Value": { "Fn::Sub": "${MyInstance.EbsVolumes0}" }
]
}
},

"OtherVolumeBurstAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
...
"Dimensions": [
{
"Name": "VolumeId",
"Value": {
"Fn::GetAtt": [
"MyInstance",
"EbsVolumes1"
]
}
]
}
},
}

This could be made more specific to allow exposing other volume properties in the future with something like:

```
Fn::GetAtt": [ "MyInstance", "EbsVolumes1VolumeId" ]
OR
Fn::GetAtt": [ "MyInstance", "EbsVolumes1:VolumeId" ]
```

## 4. Suggest specific test cases

#### Common use case: Creating alarms for metrics on the root volume
#### Test case recommendation: it should be able to deal with non-ebs volumes listed in the `BlockDeviceMapping` property.
#### Test case recommendation: it should still work (for the root volume) when no `BlockDeviceMapping` property is specified (when defaults from the AMI are used)

## 6. Category (required) - Will help with tagging and be easier to find by other users to +1

1. Compute (EC2, ECS, EKS, Lambda...)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.