AWSAT001

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: 6 Imported by: 0

README

AWSAT001

The AWSAT001 analyzer reports when a resource.TestMatchResourceAttr() call references an Amazon Resource Name (ARN) attribute. It is preferred to use resource.TestCheckResourceAttrPair() or one one of the available Terraform AWS Provider ARN testing check functions instead building full ARN regular expressions. These testing helper functions consider the value of the AWS Account ID, Partition, and Region of the acceptance test runner.

The resource.TestCheckResourceAttrPair() call can be used when the Terraform state has the ARN value already available, such as when the current resource is referencing an ARN attribute of another resource.

Otherwise, available ARN testing check functions include:

  • acctest.CheckResourceAttrGlobalARN
  • acctest.CheckResourceAttrGlobalARNNoAccount
  • acctest.CheckResourceAttrRegionalARN
  • acctest.MatchResourceAttrGlobalARN
  • acctest.MatchResourceAttrRegionalARN
  • acctest.CheckResourceAttrRegionalARNNoAccount
  • acctest.CheckResourceAttrRegionalARNAccountID
  • acctest.CheckResourceAttrGlobalARNAccountID

Flagged Code

resource.TestMatchResourceAttr("aws_lb_listener.test", "certificate_arn", regexp.MustCompile(`^arn:[^:]+:acm:[^:]+:[^:]+:certificate/.+$`))

Passing Code

resource.TestCheckResourceAttrPair("aws_lb_listener.test", "certificate_arn", "aws_acm_certificate.test", "arn")

acctest.MatchResourceAttrRegionalARN("aws_lb_listener.test", "certificate_arn", "acm", regexp.MustCompile(`certificate/.+`))

Ignoring Check

The check can be ignored for a certain line via a //lintignore:AWSAT001 comment on the previous line or at the end of the offending line, e.g.

//lintignore:AWSAT001
resource.TestMatchResourceAttr("aws_lb_listener.test", "certificate_arn", regexp.MustCompile(`^arn:[^:]+:acm:[^:]+:[^:]+:certificate/.+$`))

Documentation

Index

Constants

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

Variables

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

Functions

func AttributeNameAppearsArnRelated

func AttributeNameAppearsArnRelated(attributeName string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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