question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

W3010 AWS::EC2::Volume requires hardcoded AvailabilityZone

See original GitHub issue

cfn-lint version: (cfn-lint --version) 0.20.0

Description of issue. Creating additional volumes require AvailabilityZone as a mandatory property.

Please provide as much information as possible: When creating additional volumes to be associated with an instance, there is a requirement to add the AvailabilityZone as a mandatory property.

AvailabilityZone The Availability Zone in which to create the new volume. Required: Yes Type: String

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html

Cfn-lint uses the CloudFormation Resource Specifications as the base to do validation. These files are included as part of the application version. Please update to the latest version of cfn-lint or update the spec files manually (cfn-lint -u)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kddejongcommented, May 14, 2019

If you are associating to an instance you can use the instance attribute too.

VolumeGetAz:
    Type: "AWS::EC2::Volume"
    Properties:
      AvailabilityZone:  !GetAtt EC2Instance.AvailabilityZone
1reaction
fatbasstardcommented, May 14, 2019

The rule is there to prevent you from hardcoding AZ’s, making going multi-region more complex.

In this an AZ is indeed needed, but it’s about how to specify this. Never “lock” it to a region/AZ in the template itself, but use parameters or intrinsic function (or something else) so the template can be deployed to other regions.

Example

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  AvailabilityZone1a:
    Type: "AWS::EC2::AvailabilityZone::Name"
    Default: "us-east-1a"
Resources:
  VolumeHardcoded:
    Type: "AWS::EC2::Volume"
    Properties:
      AvailabilityZone: "us-east-1a" # Hardcoded
  VolumeParameter:
    Type: "AWS::EC2::Volume"
    Properties:
      AvailabilityZone: !Ref "AvailabilityZone1a"
  VolumeGetAz:
    Type: "AWS::EC2::Volume"
    Properties:
      AvailabilityZone: !Select
        - 0
        - Fn::GetAZs: !Ref 'AWS::Region'

In this template, only the first one (hardcoded one) generated an error (The W3010 warning in this case). The other 2 are “dynamic” ways of specifying the AZ.

Read more comments on GitHub >

github_iconTop Results From Across the Web

W3010 AWS::EC2::Volume requires hardcoded ... - GitHub
When creating additional volumes to be associated with an instance, there is a requirement to add the AvailabilityZone as a mandatory property.
Read more >
AWS::EC2::Volume - AWS CloudFormation
Specifies an Amazon Elastic Block Store (Amazon EBS) volume. You can attach the volume to an instance in the same Availability Zone using ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found