AWSAT002

package
v0.0.0-...-724c62b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

README

AWSAT002

The AWSAT002 analyzer reports hardcoded AMI IDs. AMI IDs are region dependent and tests will fail in any region or partition other than where the AMI was created.

Flagged Code

func testAccEC2SpotFleetRequestConfig(rName string, rInt int, validUntil string) string {
	return testAccEC2SpotFleetRequestConfigBase(rName, rInt) + fmt.Sprintf(`
resource "aws_spot_fleet_request" "test" {
    launch_specification {
        instance_type = "m1.small"
        ami = "ami-516b9131"
    }
}
`, validUntil)
}

Passing Code

func testAccEC2SpotFleetRequestConfig(rName string, rInt int, validUntil string) string {
    return testAccEC2SpotFleetRequestConfigBase(rName, rInt) + fmt.Sprintf(`
data "aws_ami" "amzn-ami-minimal-hvm-ebs" {
  most_recent = true
  owners      = ["amazon"]

  filter {
    name   = "name"
    values = ["amzn-ami-minimal-hvm-*"]
  }

  filter {
    name   = "root-device-type"
    values = ["ebs"]
  }
}

resource "aws_spot_fleet_request" "test" {
    launch_specification {
        instance_type = "m1.small"
        ami = data.aws_ami.amzn-ami-minimal-hvm-ebs.id
    }
}
`, validUntil)
}

Ignoring Reports

Singular reports can be ignored by adding the a //lintignore:AWSAT002 Go code comment at the end of the offending line or on the line immediately proceding, e.g.

ami = "ami-516b9131" //lintignore:AWSAT002

Documentation

Overview

Package AWSAT002 defines an Analyzer that checks for hardcoded AMI IDs

Index

Constants

View Source
const Doc = `` /* 192-byte string literal not displayed */

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: analyzerName,
	Doc:  Doc,
	Requires: []*analysis.Analyzer{
		commentignore.Analyzer,
		inspect.Analyzer,
	},
	Run: run,
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL