acctest

package
v6.0.0-...-02ba6c8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MPL-2.0 Imports: 107 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Provider name for single configuration testing
	ProviderName = "aws"

	// Provider name for alternate configuration testing
	ProviderNameAlternate = "awsalternate"

	// Provider name for echo provider
	// used for testing ephemeral resources
	ProviderNameEcho = "echo"

	// Provider name for alternate account and alternate region configuration testing
	ProviderNameAlternateAccountAlternateRegion = "awsalternateaccountalternateregion"

	// Provider name for alternate account and same region configuration testing
	ProviderNameAlternateAccountSameRegion = "awsalternateaccountsameregion"

	// Provider name for same account and alternate region configuration testing
	ProviderNameSameAccountAlternateRegion = "awssameaccountalternateregion"

	// Provider name for third configuration testing
	ProviderNameThird = "awsthird"

	// Provider name for fourth configuration testing
	ProviderNameFourth = "awsfourth"

	ResourcePrefix = "tf-acc-test"

	CertificateIssueTimeout = 5 * time.Minute
)
View Source
const (
	Ct12Digit               = "123456789012"
	CtBasic                 = "basic"
	CtCertificatePEM        = "certificate_pem"
	CtDisappears            = "disappears"
	CtFalse                 = "false"
	CtFalseCaps             = "FALSE"
	CtKey1                  = "key1"
	CtKey2                  = "key2"
	CtName                  = "name"
	CtOverlapKey1           = "overlapkey1"
	CtOverlapKey2           = "overlapkey2"
	CtPrivateKeyPEM         = "private_key_pem"
	CtProviderKey1          = "providerkey1"
	CtProviderTags          = "provider_tags"
	CtProviderValue1        = "providervalue1"
	CtProviderValue1Again   = "providervalue1again"
	CtProviderValue1Updated = "providervalue1updated"
	CtRName                 = "rName"
	CtResourceKey1          = "resourcekey1"
	CtResourceKey2          = "resourcekey2"
	CtResourceOwner         = "resource_owner"
	CtResourceTags          = "resource_tags"
	CtResourceValue1        = "resourcevalue1"
	CtResourceValue1Again   = "resourcevalue1again"
	CtResourceValue1Updated = "resourcevalue1updated"
	CtResourceValue2        = "resourcevalue2"
	CtResourceValue2Updated = "resourcevalue2updated"
	CtRulePound             = "rule.#"
	CtTagsAllPercent        = "tags_all.%"
	CtTagsKey1              = "tags.key1"
	CtTagsKey2              = "tags.key2"
	CtTagsPercent           = "tags.%"
	CtTrue                  = "true"
	CtTrueCaps              = "TRUE"
	CtValue1                = "value1"
	CtValue1Updated         = "value1updated"
	CtValue2                = "value2"
)
View Source
const (
	PEMBlockTypeCertificate        = `CERTIFICATE`
	PEMBlockTypeCertificateRequest = `CERTIFICATE REQUEST`
	PEMBlockTypeECPrivateKey       = `EC PRIVATE KEY`
	PEMBlockTypeRSAPrivateKey      = `RSA PRIVATE KEY`
	PEMBlockTypePublicKey          = `PUBLIC KEY`
)
View Source
const DefaultEmailAddress = "[email protected]"

DefaultEmailAddress is the default email address to set as a resource or data source parameter for acceptance tests.

View Source
const RFC3339RegexPattern = `` /* 148-byte string literal not displayed */

Variables

View Source
var (
	ProtoV5ProviderFactories map[string]func() (tfprotov5.ProviderServer, error) = protoV5ProviderFactoriesInit(context.Background(), ProviderName)
)

ProtoV5ProviderFactories is a static map containing only the main provider instance

Use other ProviderFactories functions, such as FactoriesAlternate, for tests requiring special provider configurations.

Provider is the "default" provider instance.

This Provider can be used in testing code for API calls without requiring the use of saving and referencing specific ProviderFactories instances.

PreCheck(t) must be called before using this provider instance.

Functions

func ACMCertificateDomainFromEnv

func ACMCertificateDomainFromEnv(t *testing.T) string

func ACMCertificateRandomSubDomain

func ACMCertificateRandomSubDomain(rootDomain string) string

ACM domain names cannot be longer than 64 characters Other resources, e.g. Cognito User Pool Domains, limit this to 63

func AccountID

func AccountID(ctx context.Context) string

AccountID returns the account ID of Provider Must be used within a resource.TestCheckFunc

func AlternateRegion

func AlternateRegion() string

func AttrImportStateIdFunc

func AttrImportStateIdFunc(resourceName, attrName string) resource.ImportStateIdFunc

AttrImportStateIdFunc is a resource.ImportStateIdFunc that returns the value of the specified attribute

func AttrsImportStateIdFunc

func AttrsImportStateIdFunc(resourceName, sep string, attrNames ...string) resource.ImportStateIdFunc

AttrsImportStateIdFunc is a resource.ImportStateIdFunc that returns the values of the specified attributes concatenated with a separator

func AvailableEC2InstanceTypeForAvailabilityZone

func AvailableEC2InstanceTypeForAvailabilityZone(availabilityZoneName string, preferredInstanceTypes ...string) string

AvailableEC2InstanceTypeForAvailabilityZone returns the configuration for a data source that describes the first available EC2 instance type offering in the specified availability zone from a list of preferred instance types. The first argument is either an Availability Zone name or Terraform configuration reference to one, e.g.

  • data.aws_availability_zones.available.names[0]
  • aws_subnet.test.availability_zone
  • us-west-2a

The data source is named 'available'.

func AvailableEC2InstanceTypeForRegion

func AvailableEC2InstanceTypeForRegion(preferredInstanceTypes ...string) string

AvailableEC2InstanceTypeForRegion returns the configuration for a data source that describes the first available EC2 instance type offering in the current region from a list of preferred instance types. The data source is named 'available'.

func AvailableEC2InstanceTypeForRegionNamed

func AvailableEC2InstanceTypeForRegionNamed(name string, preferredInstanceTypes ...string) string

AvailableEC2InstanceTypeForRegionNamed returns the configuration for a data source that describes the first available EC2 instance type offering in the current region from a list of preferred instance types. The data source name is configurable.

func CheckACMPCACertificateAuthorityActivateRootCA

func CheckACMPCACertificateAuthorityActivateRootCA(ctx context.Context, certificateAuthority *acmpcatypes.CertificateAuthority) resource.TestCheckFunc

func CheckACMPCACertificateAuthorityActivateSubordinateCA

func CheckACMPCACertificateAuthorityActivateSubordinateCA(ctx context.Context, rootCertificateAuthority, certificateAuthority *acmpcatypes.CertificateAuthority) resource.TestCheckFunc

func CheckACMPCACertificateAuthorityDisableCA

func CheckACMPCACertificateAuthorityDisableCA(ctx context.Context, certificateAuthority *acmpcatypes.CertificateAuthority) resource.TestCheckFunc

func CheckACMPCACertificateAuthorityExists

func CheckACMPCACertificateAuthorityExists(ctx context.Context, n string, certificateAuthority *acmpcatypes.CertificateAuthority) resource.TestCheckFunc

func CheckCallerIdentityAccountID

func CheckCallerIdentityAccountID(ctx context.Context, n string) resource.TestCheckFunc

func CheckDestroyNoop

func CheckDestroyNoop(*terraform.State) error

CheckDestroyNoop is a TestCheckFunc to be used as a TestCase's CheckDestroy when no such check can be made.

func CheckFrameworkResourceDisappears

func CheckFrameworkResourceDisappears(
	ctx context.Context,
	t *testing.T,
	factory func(context.Context) (fwresource.ResourceWithConfigure, error),
	n string,
) resource.TestCheckFunc

CheckFrameworkResourceDisappears destroys an existing resource out of band

By default, this check will only copy root-level string arguments into the state used to delete the remote resource. For resources requiring nested or non-string arguments to be available for the delete operation, consider using CheckFrameworkResourceDisappearsWithStateFunc with a custom state function instead.

func CheckFrameworkResourceDisappearsWithStateFunc

func CheckFrameworkResourceDisappearsWithStateFunc(
	ctx context.Context,
	t *testing.T,
	factory func(context.Context) (fwresource.ResourceWithConfigure, error),
	n string,
	stateFunc func(ctx context.Context, state *tfsdk.State, is *terraform.InstanceState) error,
) resource.TestCheckFunc

CheckFrameworkResourceDisappearsWithStateFunc destroys an existing resource out of band, constructing state from the provided state function

func CheckResourceAttrAccountID

func CheckResourceAttrAccountID(ctx context.Context, resourceName, attributeName string) resource.TestCheckFunc

CheckResourceAttrAccountID ensures the Terraform state exactly matches the account ID

func CheckResourceAttrContains

func CheckResourceAttrContains(name, key, substr string) resource.TestCheckFunc

CheckResourceAttrContains ensures the Terraform state value contains the specified substr.

func CheckResourceAttrEquivalentJSON

func CheckResourceAttrEquivalentJSON(n, key, expectedJSON string) resource.TestCheckFunc

CheckResourceAttrEquivalentJSON is a TestCheckFunc that compares a JSON value with an expected value. Both JSON values are normalized before being compared.

func CheckResourceAttrGlobalARN

func CheckResourceAttrGlobalARN(ctx context.Context, resourceName, attributeName, arnService, arnResource string) resource.TestCheckFunc

CheckResourceAttrGlobalARN ensures the Terraform state exactly matches a formatted ARN without region

func CheckResourceAttrGlobalARNAccountID

func CheckResourceAttrGlobalARNAccountID(resourceName, attributeName, accountID, arnService, arnResource string) resource.TestCheckFunc

CheckResourceAttrGlobalARNAccountID ensures the Terraform state exactly matches a formatted ARN without region and with specific account ID

func CheckResourceAttrGlobalARNFormat

func CheckResourceAttrGlobalARNFormat(ctx context.Context, resourceName, attributeName, arnService, arnFormat string) resource.TestCheckFunc

func CheckResourceAttrGlobalARNNoAccount

func CheckResourceAttrGlobalARNNoAccount(resourceName, attributeName, arnService, arnResource string) resource.TestCheckFunc

CheckResourceAttrGlobalARNNoAccount ensures the Terraform state exactly matches a formatted ARN without region or account ID

func CheckResourceAttrGlobalARNNoAccountFormat

func CheckResourceAttrGlobalARNNoAccountFormat(resourceName, attributeName, arnService, arnFormat string) resource.TestCheckFunc

func CheckResourceAttrGreaterThanOrEqualValue

func CheckResourceAttrGreaterThanOrEqualValue(n, key string, val int) resource.TestCheckFunc

func CheckResourceAttrGreaterThanValue

func CheckResourceAttrGreaterThanValue(n, key string, val int) resource.TestCheckFunc

func CheckResourceAttrHasPrefix

func CheckResourceAttrHasPrefix(name, key, prefix string) resource.TestCheckFunc

CheckResourceAttrHasPrefix ensures the Terraform state value has the specified prefix.

func CheckResourceAttrHasSuffix

func CheckResourceAttrHasSuffix(name, key, suffix string) resource.TestCheckFunc

CheckResourceAttrHasSuffix ensures the Terraform state value has the specified suffix.

func CheckResourceAttrIsJSONString

func CheckResourceAttrIsJSONString(n, key string) resource.TestCheckFunc

func CheckResourceAttrJMES

func CheckResourceAttrJMES(name, key, jmesPath, value string) resource.TestCheckFunc

func CheckResourceAttrJMESNotExists

func CheckResourceAttrJMESNotExists(name, key, jmesPath string) resource.TestCheckFunc

func CheckResourceAttrJMESPair

func CheckResourceAttrJMESPair(nameFirst, keyFirst, jmesPath, nameSecond, keySecond string) resource.TestCheckFunc

func CheckResourceAttrJSONNoDiff

func CheckResourceAttrJSONNoDiff(n, key, expectedJSON string) resource.TestCheckFunc

func CheckResourceAttrNameFromPrefix

func CheckResourceAttrNameFromPrefix(resourceName string, attributeName string, prefix string) resource.TestCheckFunc

CheckResourceAttrNameFromPrefix verifies that the state attribute value matches name generated from given prefix

func CheckResourceAttrNameGenerated

func CheckResourceAttrNameGenerated(resourceName string, attributeName string) resource.TestCheckFunc

CheckResourceAttrNameGenerated verifies that the state attribute value matches name automatically generated without prefix

func CheckResourceAttrNameGeneratedWithPrefix

func CheckResourceAttrNameGeneratedWithPrefix(resourceName string, attributeName string, prefix string) resource.TestCheckFunc

CheckResourceAttrNameGeneratedWithPrefix verifies that the state attribute value matches name automatically generated with prefix

func CheckResourceAttrNameWithSuffixFromPrefix

func CheckResourceAttrNameWithSuffixFromPrefix(resourceName string, attributeName string, prefix string, suffix string) resource.TestCheckFunc

CheckResourceAttrNameWithSuffixFromPrefix verifies that the state attribute value matches name with suffix generated from given prefix

func CheckResourceAttrNameWithSuffixGenerated

func CheckResourceAttrNameWithSuffixGenerated(resourceName string, attributeName string, suffix string) resource.TestCheckFunc

CheckResourceAttrNameWithSuffixGenerated verifies that the state attribute value matches name with suffix automatically generated without prefix

func CheckResourceAttrRFC3339

func CheckResourceAttrRFC3339(resourceName, attributeName string) resource.TestCheckFunc

CheckResourceAttrRFC3339 ensures the Terraform state matches a RFC3339 value This TestCheckFunc will likely be moved to the Terraform Plugin SDK in the future.

func CheckResourceAttrRegionalARN

func CheckResourceAttrRegionalARN(ctx context.Context, resourceName, attributeName, arnService, arnResource string) resource.TestCheckFunc

CheckResourceAttrRegionalARN ensures the Terraform state exactly matches a formatted ARN with region

func CheckResourceAttrRegionalARNAccountID

func CheckResourceAttrRegionalARNAccountID(resourceName, attributeName, arnService, accountID, arnResource string) resource.TestCheckFunc

CheckResourceAttrRegionalARNAccountID ensures the Terraform state exactly matches a formatted ARN with region and specific account ID

func CheckResourceAttrRegionalARNFormat

func CheckResourceAttrRegionalARNFormat(ctx context.Context, resourceName, attributeName, arnService, arnFormat string) resource.TestCheckFunc

func CheckResourceAttrRegionalARNIgnoreRegionAndAccount

func CheckResourceAttrRegionalARNIgnoreRegionAndAccount(resourceName, attributeName, arnService, arnResource string) resource.TestCheckFunc

CheckResourceAttrRegionalARNIgnoreRegionAndAccount ensures the Terraform state exactly matches a formatted ARN with region without specifying the region or account

func CheckResourceAttrRegionalARNNoAccount

func CheckResourceAttrRegionalARNNoAccount(resourceName, attributeName, arnService, arnResource string) resource.TestCheckFunc

CheckResourceAttrRegionalARNNoAccount ensures the Terraform state exactly matches a formatted ARN with region but without account ID

func CheckResourceAttrRegionalHostnameService

func CheckResourceAttrRegionalHostnameService(resourceName, attributeName, serviceName string) resource.TestCheckFunc

CheckResourceAttrRegionalHostnameService ensures the Terraform state exactly matches a service DNS hostname with region and partition DNS suffix

For example: ec2.us-west-2.amazonaws.com

func CheckSDKResourceDisappears

func CheckSDKResourceDisappears(ctx context.Context, t *testing.T, resource *schema.Resource, n string) resource.TestCheckFunc

func CheckSDKResourceDisappearsWithProvider

func CheckSDKResourceDisappearsWithProvider(ctx context.Context, provider *schema.Provider, resource *schema.Resource, n string) resource.TestCheckFunc

func CheckSleep

func CheckSleep(t *testing.T, d time.Duration) resource.TestCheckFunc

CheckSleep returns a TestCheckFunc that pauses the current goroutine for at least the duration d.

func CheckVPCExists

func CheckVPCExists(ctx context.Context, t *testing.T, n string, v *ec2types.Vpc) resource.TestCheckFunc

func CheckWithNamedProviders

func CheckWithNamedProviders(f TestCheckWithProviderFunc, providers map[string]*schema.Provider) resource.TestCheckFunc

func CheckWithProviders

func CheckWithProviders(f TestCheckWithProviderFunc, providers *[]*schema.Provider) resource.TestCheckFunc

func CheckWithRegions

func CheckWithRegions(f TestCheckWithRegionFunc, regions ...string) resource.TestCheckFunc

func ComposeAggregateImportStateCheckFunc

func ComposeAggregateImportStateCheckFunc(fs ...resource.ImportStateCheckFunc) resource.ImportStateCheckFunc

ComposeAggregateImportStateCheckFunc lets you compose multiple ImportStateCheckFunc into a single ImportStateCheckFunc.

func ConfigAlternateAccountAlternateRegionProvider

func ConfigAlternateAccountAlternateRegionProvider() string

func ConfigAlternateAccountProvider

func ConfigAlternateAccountProvider() string

func ConfigAlternateRegionProvider deprecated

func ConfigAlternateRegionProvider() string

Deprecated: Use ConfigMultipleRegionProvider instead

func ConfigAssumeRole

func ConfigAssumeRole() string

func ConfigAssumeRolePolicy

func ConfigAssumeRolePolicy(policy string) string

func ConfigAvailableAZsNoOptIn

func ConfigAvailableAZsNoOptIn() string

func ConfigAvailableAZsNoOptInDefaultExclude

func ConfigAvailableAZsNoOptInDefaultExclude() string

func ConfigAvailableAZsNoOptInDefaultExclude_RegionOverride

func ConfigAvailableAZsNoOptInDefaultExclude_RegionOverride(region string) string

func ConfigAvailableAZsNoOptInExclude

func ConfigAvailableAZsNoOptInExclude(excludeZoneIds ...string) string

func ConfigAvailableAZsNoOptInExclude_RegionOverride

func ConfigAvailableAZsNoOptInExclude_RegionOverride(region string, excludeZoneIds ...string) string

func ConfigBedrockAgentKnowledgeBaseS3VectorsBase

func ConfigBedrockAgentKnowledgeBaseS3VectorsBase(rName string) string

func ConfigCompose

func ConfigCompose(config ...string) string

ConfigCompose can be called to concatenate multiple strings to build test configurations

func ConfigDefaultAndIgnoreTagsKeyPrefixes1

func ConfigDefaultAndIgnoreTagsKeyPrefixes1(key1, value1, keyPrefix1 string) string

func ConfigDefaultAndIgnoreTagsKeys1

func ConfigDefaultAndIgnoreTagsKeys1(key1, value1 string) string

func ConfigDefaultTags_Tags0

func ConfigDefaultTags_Tags0() string

func ConfigDefaultTags_Tags1

func ConfigDefaultTags_Tags1(tag1, value1 string) string

func ConfigDefaultTags_Tags2

func ConfigDefaultTags_Tags2(tag1, value1, tag2, value2 string) string

func ConfigIgnoreTagsKeyPrefixes1

func ConfigIgnoreTagsKeyPrefixes1(keyPrefix1 string) string

func ConfigIgnoreTagsKeys

func ConfigIgnoreTagsKeys(key1 string) string

func ConfigLambdaBase

func ConfigLambdaBase(policyName, roleName, sgName string) string

func ConfigLatestAmazonLinux2HVMEBSARM64AMI

func ConfigLatestAmazonLinux2HVMEBSARM64AMI() string

ConfigLatestAmazonLinux2HVMEBSARM64AMI returns the configuration for a data source that describes the latest Amazon Linux 2 arm64 AMI using HVM virtualization and an EBS root device. The data source is named 'amzn2-ami-minimal-hvm-ebs-arm64'.

func ConfigLatestAmazonLinux2HVMEBSX8664AMI

func ConfigLatestAmazonLinux2HVMEBSX8664AMI() string

ConfigLatestAmazonLinux2HVMEBSX8664AMI returns the configuration for a data source that describes the latest Amazon Linux 2 x86_64 AMI using HVM virtualization and an EBS root device. The data source is named 'amzn2-ami-minimal-hvm-ebs-x86_64'.

func ConfigMultipleAccountProvider

func ConfigMultipleAccountProvider(t *testing.T, accounts int) string

func ConfigMultipleRegionProvider

func ConfigMultipleRegionProvider(regions int) string

func ConfigNamedAccountProvider

func ConfigNamedAccountProvider(providerName, accessKey, profile, secretKey string) string

ConfigNamedAccountProvider creates a new provider named configuration with a region.

This can be used to build multiple provider configuration testing.

func ConfigNamedAlternateAccountAlternateRegionProvider

func ConfigNamedAlternateAccountAlternateRegionProvider(providerName string) string

func ConfigNamedRegionalProvider

func ConfigNamedRegionalProvider(providerName string, region string) string

ConfigNamedRegionalProvider creates a new named provider configuration with a region.

This can be used to build multiple provider configuration testing.

func ConfigProviderMeta

func ConfigProviderMeta() string

ConfigProviderMeta returns a terraform block with provider_meta configured

func ConfigRandomPassword

func ConfigRandomPassword(overrides ...string) string

ConfigRandomPassword returns the configuration for an ephemeral resource that describes a random password.

The ephemeral resource is named 'test'. Use ephemeral.aws_secretsmanager_random_password.test.random_password to reference the password value, assigning it to a write-only argument ("_wo").

The function accepts a variable number of string arguments in the format "key=value". The following keys are supported:

  • password_length: The length of the password. Default is 20.
  • exclude_punctuation: Whether to exclude punctuation characters. Default is true.
  • exclude_characters: A string of characters to exclude from the password.
  • exclude_lowercase: Whether to exclude lowercase letters. Default is false.
  • exclude_numbers: Whether to exclude numbers. Default is false.
  • exclude_uppercase: Whether to exclude uppercase letters. Default is false.
  • include_space: Whether to include a space character. Default is false.
  • require_each_included_type: Whether to require at least one character from each included type. Default is false.

Called without overrides, the function returns the default configuration:

ephemeral "aws_secretsmanager_random_password" "test" {
  password_length     = 20
  exclude_punctuation = true
}

func ConfigRegionalProvider

func ConfigRegionalProvider(region string) string

ConfigRegionalProvider creates a new provider configuration with a region.

This can only be used for single provider configuration testing as it overwrites the "aws" provider configuration.

func ConfigSkipCredentialsValidationAndRequestingAccountID

func ConfigSkipCredentialsValidationAndRequestingAccountID() string

func ConfigSubnets

func ConfigSubnets(rName string, subnetCount int) string

func ConfigSubnetsIPv6

func ConfigSubnetsIPv6(rName string, subnetCount int) string

func ConfigTagPolicyCompliance

func ConfigTagPolicyCompliance(severity string) string

ConfigTagPolicyCompliance enables tag policy enforcement with the provided severity

func ConfigTagPolicyComplianceAndDefaultTags1

func ConfigTagPolicyComplianceAndDefaultTags1(severity, key1, value1 string) string

ConfigTagPolicyComplianceAndDefaultTags1 enables tag policy enforcement with the provided severity and a default tag

func ConfigVPCWithSubnets

func ConfigVPCWithSubnets(rName string, subnetCount int) string

func ConfigVPCWithSubnetsEnableDNSHostnames

func ConfigVPCWithSubnetsEnableDNSHostnames(rName string, subnetCount int) string

func ConfigVPCWithSubnetsIPv6

func ConfigVPCWithSubnetsIPv6(rName string, subnetCount int) string

func ConfigVPCWithSubnets_RegionOverride

func ConfigVPCWithSubnets_RegionOverride(rName string, subnetCount int, region string) string

func ConfigWithEchoProvider

func ConfigWithEchoProvider(ephemeralResourceData string) string

func Context

func Context(t *testing.T) context.Context

func CrossRegionAttrImportStateIdFunc

func CrossRegionAttrImportStateIdFunc(resourceName, attrName string) resource.ImportStateIdFunc

CrossRegionAttrImportStateIdFunc is a resource.ImportStateIdFunc that returns the value of the specified attribute and appends the region

func CrossRegionImportStateIdFunc

func CrossRegionImportStateIdFunc(resourceName string) resource.ImportStateIdFunc

CrossRegionImportStateIdFunc is a resource.ImportStateIdFunc that appends the region

func CrossRegionImportStateIdFuncAdapter

func CrossRegionImportStateIdFuncAdapter(resourceName string, f Func) resource.ImportStateIdFunc

CrossRegionImportStateIdFuncAdapter adapts an ImportStateIdFunc by appending the region

func DeleteResource

func DeleteResource(ctx context.Context, resource *schema.Resource, d *schema.ResourceData, meta any) error

func ErrorCheck

func ErrorCheck(t *testing.T, serviceIDs ...string) resource.ErrorCheckFunc

func ErrorCheckSequence

func ErrorCheckSequence(funcs ...resource.ErrorCheckFunc) resource.ErrorCheckFunc

func ErrorCheckSkipMessagesContaining

func ErrorCheckSkipMessagesContaining(t *testing.T, needles ...string) resource.ErrorCheckFunc

ErrorCheckSkipMessagesContaining skips tests based on error messages that contain one of the specified needles.

func ErrorCheckSkipMessagesMatches

func ErrorCheckSkipMessagesMatches(t *testing.T, rs ...*regexp.Regexp) resource.ErrorCheckFunc

ErrorCheckSkipMessagesMatches skips tests based on error messages that match one of the specified regular expressions.

func ExpectErrorAttrAtLeastOneOf

func ExpectErrorAttrAtLeastOneOf(attrs ...string) *regexp.Regexp

func ExpectErrorAttrMinItems

func ExpectErrorAttrMinItems(attr string, expected, actual int) *regexp.Regexp

func FourthRegion

func FourthRegion() string

func GlobalARN

func GlobalARN(arnService, arnResource string) globalARNCheck

func ImportCheckNoResourceAttr

func ImportCheckNoResourceAttr(key string) resource.ImportStateCheckFunc

func ImportCheckResourceAttr

func ImportCheckResourceAttr(key, expected string) resource.ImportStateCheckFunc

func ImportCheckResourceAttrSet

func ImportCheckResourceAttrSet(key string) resource.ImportStateCheckFunc

func ImportMatchResourceAttr

func ImportMatchResourceAttr(key string, r *regexp.Regexp) resource.ImportStateCheckFunc

func ImportStateIDAccountID

func ImportStateIDAccountID(ctx context.Context) resource.ImportStateIdFunc

func IsIsolatedPartition

func IsIsolatedPartition(partition string) bool

func IsIsolatedRegion

func IsIsolatedRegion(region string) bool

func IsStandardPartition

func IsStandardPartition(partitionID string) bool

func IsStandardRegion

func IsStandardRegion(region string) bool

func ListOfStrings

func ListOfStrings[E ~string](s ...E) string

func MatchResourceAttrAccountID

func MatchResourceAttrAccountID(resourceName, attributeName string) resource.TestCheckFunc

MatchResourceAttrAccountID ensures the Terraform state regexp matches an account ID

func MatchResourceAttrGlobalARN

func MatchResourceAttrGlobalARN(ctx context.Context, resourceName, attributeName, arnService string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrGlobalARN ensures the Terraform state regexp matches a formatted ARN without region

func MatchResourceAttrGlobalARNNoAccount

func MatchResourceAttrGlobalARNNoAccount(resourceName, attributeName, arnService string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrGlobalARNNoAccount ensures the Terraform state regexp matches a formatted ARN without region or account ID

func MatchResourceAttrGlobalHostname

func MatchResourceAttrGlobalHostname(resourceName, attributeName, serviceName string, hostnamePrefixRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrGlobalHostname ensures the Terraform state regexp matches a formatted DNS hostname with partition DNS suffix and without region

func MatchResourceAttrRegionalARN

func MatchResourceAttrRegionalARN(ctx context.Context, resourceName, attributeName, arnService string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrRegionalARN ensures the Terraform state regexp matches a formatted ARN with region

func MatchResourceAttrRegionalARNAccountID

func MatchResourceAttrRegionalARNAccountID(resourceName, attributeName, arnService, accountID string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrRegionalARNAccountID ensures the Terraform state regexp matches a formatted ARN with region and specific account ID

func MatchResourceAttrRegionalARNNoAccount

func MatchResourceAttrRegionalARNNoAccount(resourceName, attributeName, arnService string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrRegionalARNNoAccount ensures the Terraform state regexp matches a formatted ARN with region but without account ID

func MatchResourceAttrRegionalARNRegion

func MatchResourceAttrRegionalARNRegion(ctx context.Context, resourceName, attributeName, arnService, region string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrRegionalARNRegion ensures the Terraform state regexp matches a formatted ARN with the specified region

func MatchResourceAttrRegionalHostname

func MatchResourceAttrRegionalHostname(resourceName, attributeName, serviceName string, hostnamePrefixRegexp *regexp.Regexp) resource.TestCheckFunc

MatchResourceAttrRegionalHostname ensures the Terraform state regexp matches a formatted DNS hostname with region and partition DNS suffix

func NamedProvider

func NamedProvider(name string, providers map[string]*schema.Provider) *schema.Provider

func ParallelTest

func ParallelTest(ctx context.Context, t *testing.T, c resource.TestCase)

ParallelTest wraps resource.ParallelTest, initializing VCR if enabled

func Partition

func Partition() string

func PartitionDNSSuffix

func PartitionDNSSuffix() string

func PartitionRegions

func PartitionRegions() []string

func PartitionReverseDNSPrefix

func PartitionReverseDNSPrefix() string

func PreCheck

func PreCheck(ctx context.Context, t *testing.T)

PreCheck verifies and sets required provider testing configuration

This PreCheck function should be present in every acceptance test. It allows test configurations to omit a provider configuration with region and ensures testing functions that attempt to call AWS APIs are previously configured.

These verifications and configuration are preferred at this level to prevent provider developers from experiencing less clear errors for every test.

func PreCheckAPIGatewayTypeEDGE

func PreCheckAPIGatewayTypeEDGE(t *testing.T)

PreCheckAPIGatewayTypeEDGE checks if endpoint config type EDGE can be used in a test and skips test if not (i.e., not in standard partition).

func PreCheckAlternateAccount

func PreCheckAlternateAccount(t *testing.T)

func PreCheckAlternateRegion

func PreCheckAlternateRegion(t *testing.T, regions ...string)

PreCheckAlternateRegion checks that the alternate test region is one of the specified AWS Regions.

func PreCheckAssumeRoleARN

func PreCheckAssumeRoleARN(t *testing.T)

func PreCheckCognitoIdentityProvider

func PreCheckCognitoIdentityProvider(ctx context.Context, t *testing.T)

func PreCheckDirectoryService

func PreCheckDirectoryService(ctx context.Context, t *testing.T)

func PreCheckDirectoryServiceSimpleDirectory

func PreCheckDirectoryServiceSimpleDirectory(ctx context.Context, t *testing.T)

Certain regions such as AWS GovCloud (US) do not support Simple AD directories and we do not have a good read-only way to determine this situation. Here we opt to perform a creation that will fail so we can determine Simple AD support.

func PreCheckFourthAccount

func PreCheckFourthAccount(t *testing.T)

add fourth region

func PreCheckFourthRegion

func PreCheckFourthRegion(t *testing.T, regions ...string)

PreCheckFourthRegion checks that the fourth test region is one of the specified AWS Regions.

func PreCheckHasIAMRole

func PreCheckHasIAMRole(ctx context.Context, t *testing.T, roleName string)

func PreCheckIAMServiceLinkedRole

func PreCheckIAMServiceLinkedRole(ctx context.Context, t *testing.T, pathPrefix string)

func PreCheckIAMServiceLinkedRoleWithProvider

func PreCheckIAMServiceLinkedRoleWithProvider(ctx context.Context, t *testing.T, providerF ProviderFunc, pathPrefix string)

func PreCheckInspector2

func PreCheckInspector2(ctx context.Context, t *testing.T)

func PreCheckMultipleRegion

func PreCheckMultipleRegion(t *testing.T, regions int)

func PreCheckOrganizationManagementAccount

func PreCheckOrganizationManagementAccount(ctx context.Context, t *testing.T)

func PreCheckOrganizationManagementAccountWithProvider

func PreCheckOrganizationManagementAccountWithProvider(ctx context.Context, t *testing.T, providerF ProviderFunc)

func PreCheckOrganizationMemberAccount

func PreCheckOrganizationMemberAccount(ctx context.Context, t *testing.T)

func PreCheckOrganizationMemberAccountWithProvider

func PreCheckOrganizationMemberAccountWithProvider(ctx context.Context, t *testing.T, providerF ProviderFunc)

func PreCheckOrganizationsAccount

func PreCheckOrganizationsAccount(ctx context.Context, t *testing.T)

func PreCheckOrganizationsEnabled

func PreCheckOrganizationsEnabled(ctx context.Context, t *testing.T) *organizationstypes.Organization

func PreCheckOrganizationsEnabledServicePrincipal

func PreCheckOrganizationsEnabledServicePrincipal(ctx context.Context, t *testing.T, servicePrincipalName string)

func PreCheckOrganizationsEnabledWithProvider

func PreCheckOrganizationsEnabledWithProvider(ctx context.Context, t *testing.T, providerF ProviderFunc) *organizationstypes.Organization

func PreCheckOutpostsOutposts

func PreCheckOutpostsOutposts(ctx context.Context, t *testing.T)

func PreCheckPartition

func PreCheckPartition(t *testing.T, partition string)

PreCheckPartition checks that the test partition is the specified partition.

func PreCheckPartitionHasService

func PreCheckPartitionHasService(t *testing.T, serviceID string)

func PreCheckPartitionNot

func PreCheckPartitionNot(t *testing.T, partitions ...string)

PreCheckPartitionNot checks that the test partition is not one of the specified partitions.

func PreCheckPinpointApp

func PreCheckPinpointApp(ctx context.Context, t *testing.T)

func PreCheckRAMSharingWithOrganizationEnabled

func PreCheckRAMSharingWithOrganizationEnabled(ctx context.Context, t *testing.T)

func PreCheckRAMSharingWithOrganizationEnabledWithProvider

func PreCheckRAMSharingWithOrganizationEnabledWithProvider(ctx context.Context, t *testing.T, providerF ProviderFunc)

func PreCheckRegion

func PreCheckRegion(t *testing.T, regions ...string)

PreCheckRegion checks that the test region is one of the specified AWS Regions.

func PreCheckRegionNot

func PreCheckRegionNot(t *testing.T, regions ...string)

PreCheckRegionNot checks that the test region is not one of the specified AWS Regions.

func PreCheckRegionOptIn

func PreCheckRegionOptIn(ctx context.Context, t *testing.T, region string)

func PreCheckResourceGroupsTaggingAPIRequiredTags

func PreCheckResourceGroupsTaggingAPIRequiredTags(ctx context.Context, t *testing.T)

func PreCheckSSOAdminInstances

func PreCheckSSOAdminInstances(ctx context.Context, t *testing.T)

func PreCheckSSOAdminInstancesWithRegion

func PreCheckSSOAdminInstancesWithRegion(ctx context.Context, t *testing.T, region string)

func PreCheckSameOrganization

func PreCheckSameOrganization(ctx context.Context, t *testing.T, providerFs ...ProviderFunc)

func PreCheckSkipError

func PreCheckSkipError(err error) bool

Check service API call error for reasons to skip acceptance testing These include missing API endpoints and unsupported API calls

func PreCheckThirdAccount

func PreCheckThirdAccount(t *testing.T)

func PreCheckThirdRegion

func PreCheckThirdRegion(t *testing.T, regions ...string)

PreCheckThirdRegion checks that the third test region is one of the specified AWS Regions.

func PreCheckWAFV2CloudFrontScope

func PreCheckWAFV2CloudFrontScope(ctx context.Context, t *testing.T)

func PrimaryInstanceState

func PrimaryInstanceState(s *terraform.State, name string) (*terraform.InstanceState, error)

Copied and inlined from the SDK testing code

func ProtoV5FactoriesAlternate

func ProtoV5FactoriesAlternate(ctx context.Context, t *testing.T) map[string]func() (tfprotov5.ProviderServer, error)

func ProtoV5FactoriesAlternateAccountAndAlternateRegion

func ProtoV5FactoriesAlternateAccountAndAlternateRegion(ctx context.Context, t *testing.T) map[string]func() (tfprotov5.ProviderServer, error)

ProtoV5FactoriesAlternateAccountAndAlternateRegion creates ProtoV5ProviderFactories for cross-account and cross-region configurations

Usage typically paired with PreCheckMultipleRegion, PreCheckAlternateAccount, and ConfigAlternateAccountAndAlternateRegionProvider.

func ProtoV5FactoriesMultipleRegions

func ProtoV5FactoriesMultipleRegions(ctx context.Context, t *testing.T, n int) map[string]func() (tfprotov5.ProviderServer, error)

ProtoV5FactoriesMultipleRegions creates ProtoV5ProviderFactories for the specified number of region configurations

Usage typically paired with PreCheckMultipleRegion and ConfigMultipleRegionProvider.

func ProtoV5FactoriesNamed

func ProtoV5FactoriesNamed(ctx context.Context, t *testing.T, providers map[string]*schema.Provider, providerNames ...string) map[string]func() (tfprotov5.ProviderServer, error)

func ProtoV5FactoriesNamedAlternate

func ProtoV5FactoriesNamedAlternate(ctx context.Context, t *testing.T, providers map[string]*schema.Provider) map[string]func() (tfprotov5.ProviderServer, error)

func ProtoV5FactoriesPlusProvidersAlternate

func ProtoV5FactoriesPlusProvidersAlternate(ctx context.Context, t *testing.T, providers *[]*schema.Provider) map[string]func() (tfprotov5.ProviderServer, error)

ProtoV5FactoriesPlusProvidersAlternate creates ProtoV5ProviderFactories for cross-account and cross-region configurations and also returns Providers suitable for use with AWS APIs.

For cross-region testing: Typically paired with PreCheckMultipleRegion and ConfigAlternateRegionProvider.

For cross-account testing: Typically paired with PreCheckAlternateAccount and ConfigAlternateAccountProvider.

func ProtoV5FactoriesPlusProvidersThird

func ProtoV5FactoriesPlusProvidersThird(ctx context.Context, t *testing.T, providers *[]*schema.Provider) map[string]func() (tfprotov5.ProviderServer, error)

func ProtoV6ProviderFactories

func ProtoV6ProviderFactories(_ context.Context, providerNames ...string) map[string]func() (tfprotov6.ProviderServer, error)

ProtoV6ProviderFactories initializes v6 provider factories currently only initializes echo provider for testing ephemeral resources

func ProviderAccountID

func ProviderAccountID(ctx context.Context, provider *schema.Provider) string

ProviderAccountID returns the account ID of an AWS provider

func ProviderMeta

func ProviderMeta(_ context.Context, t *testing.T) *conns.AWSClient

ProviderMeta returns the current provider's state (AKA "meta" or "conns.AWSClient")

func RandInt

func RandInt(t *testing.T) int

RandInt is a VCR-friendly replacement for acctest.RandInt

func RandIntRange

func RandIntRange(t *testing.T, minInt int, maxInt int) int

RandIntRange is a VCR-friendly replacement for acctest.RandIntRange

func RandomDomain

func RandomDomain() domainName

func RandomDomainName

func RandomDomainName() string

RandomDomainName creates a random two-level domain name in the form "<random>.test" The top level domain ".test" is reserved by IANA for testing purposes: https://datatracker.ietf.org/doc/html/rfc6761

func RandomEmailAddress

func RandomEmailAddress(domainName string) string

RandomEmailAddress generates a random email address in the form "tf-acc-test-<random>@<domain>"

func RandomFQDomainName

func RandomFQDomainName() string

RandomFQDomainName creates a random fully-qualified two-level domain name in the form "<random>.test." The top level domain ".test" is reserved by IANA for testing purposes: https://datatracker.ietf.org/doc/html/rfc6761

func RandomSubdomain

func RandomSubdomain() string

RandomSubdomain creates a random three-level domain name in the form "<random>.<random>.test" The top level domain ".test" is reserved by IANA for testing purposes: https://datatracker.ietf.org/doc/html/rfc6761

func RandomWithPrefix

func RandomWithPrefix(t *testing.T, prefix string) string

RandomWithPrefix is a VCR-friendly replacement for acctest.RandomWithPrefix

func Region

func Region() string

func RegionsInPartition

func RegionsInPartition(partitionName string) []string

func RegisterServiceErrorCheckFunc

func RegisterServiceErrorCheckFunc(serviceID string, f ServiceErrorCheckFunc)

func RunLimitedConcurrencyTests2Levels

func RunLimitedConcurrencyTests2Levels(t *testing.T, semaphore tfsync.Semaphore, testCases map[string]map[string]func(*testing.T, tfsync.Semaphore))

RunLimitedConcurrencyTests2Levels runs test cases with concurrency limited via `semaphore`.

func RunSerialTests1Level

func RunSerialTests1Level(t *testing.T, testCases map[string]func(*testing.T), d time.Duration)

RunSerialTests1Level runs test cases in parallel, optionally sleeping between each.

func RunSerialTests2Levels

func RunSerialTests2Levels(t *testing.T, testCases map[string]map[string]func(*testing.T), d time.Duration)

RunSerialTests2Levels runs test cases in parallel, optionally sleeping between each.

func S3BucketHasTag

func S3BucketHasTag(ctx context.Context, bucketName, key, value string) resource.TestCheckFunc

func Skip

func Skip(t *testing.T, message string)

Skip implements a wrapper for (*testing.T).Skip() to prevent unused linting reports

Reference: https://github.com/dominikh/go-tools/issues/633#issuecomment-606560616

func SkipIfEnvVarNotSet

func SkipIfEnvVarNotSet(t *testing.T, key string) string

SkipIfEnvVarNotSet skips the current test if the specified environment variable is not set. The variable's value is returned.

func SkipIfExeNotOnPath

func SkipIfExeNotOnPath(t *testing.T, file string) string

SkipIfExeNotOnPath skips the current test if the specified executable is not found in the directories named by the PATH environment variable. The absolute path to the executable is returned.

func SkipIfNotRunningAcceptanceTests

func SkipIfNotRunningAcceptanceTests(t *testing.T)

SkipIfNotRunningAcceptanceTests skips the current test if it's not an acceptance test (TF_ACC is set in the environment).

func TLSECDSAPrivateKeyPEM

func TLSECDSAPrivateKeyPEM(t *testing.T, curveName string) string

TLSECDSAPublicKeyPEM generates an ECDSA private key PEM string using the specified elliptic curve. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: private_key_pem = "%[1]s"

func TLSECDSAPublicKeyPEM

func TLSECDSAPublicKeyPEM(t *testing.T, keyPem string) (string, string)

TLSECDSAPublicKeyPEM generates an ECDSA public key PEM string and fingerprint.

func TLSPEMEscapeNewlines

func TLSPEMEscapeNewlines(pem string) string

func TLSPEMRemoveNewlines

func TLSPEMRemoveNewlines(pem string) string

func TLSPEMRemovePublicKeyEncapsulationBoundaries

func TLSPEMRemovePublicKeyEncapsulationBoundaries(pem string) string

TLSPEMRemovePublicKeyEncapsulationBoundaries removes public key pre and post encapsulation boundaries from a PEM string.

func TLSPEMRemoveRSAPrivateKeyEncapsulationBoundaries

func TLSPEMRemoveRSAPrivateKeyEncapsulationBoundaries(pem string) string

TLSPEMRemoveRSAPrivateKeyEncapsulationBoundaries removes RSA private key pre and post encapsulation boundaries from a PEM string.

func TLSRSAPrivateKeyPEM

func TLSRSAPrivateKeyPEM(t *testing.T, bits int) string

TLSRSAPrivateKeyPEM generates a RSA private key PEM string. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: private_key_pem = "%[1]s"

func TLSRSAPublicKeyPEM

func TLSRSAPublicKeyPEM(t *testing.T, keyPem string) string

TLSRSAPublicKeyPEM generates a RSA public key PEM string. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: public_key_pem = "%[1]s"

func TLSRSAX509CertificateRequestPEM

func TLSRSAX509CertificateRequestPEM(t *testing.T, keyBits int, commonName string) (string, string)

TLSRSAX509CertificateRequestPEM generates a x509 certificate request PEM string and a RSA private key PEM string. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: certificate_signing_request_pem = "%[1]s" private_key_pem = "%[2]s"

func TLSRSAX509LocallySignedCertificatePEM

func TLSRSAX509LocallySignedCertificatePEM(t *testing.T, caKeyPem, caCertificatePem, keyPem, commonName string) string

TLSRSAX509LocallySignedCertificatePEM generates a local CA x509 certificate PEM string. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: certificate_pem = "%[1]s"

func TLSRSAX509SelfSignedCACertificateForRolesAnywhereTrustAnchorPEM

func TLSRSAX509SelfSignedCACertificateForRolesAnywhereTrustAnchorPEM(t *testing.T, keyPem string) string

TLSRSAX509SelfSignedCACertificateForRolesAnywhereTrustAnchorPEM generates a x509 CA certificate PEM string. The CA certificate is suitable for use as an IAM RolesAnywhere Trust Anchor. See https://docs.aws.amazon.com/rolesanywhere/latest/userguide/trust-model.html#signature-verification. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: root_certificate_pem = "%[1]s"

func TLSRSAX509SelfSignedCACertificatePEM

func TLSRSAX509SelfSignedCACertificatePEM(t *testing.T, keyPem string) string

TLSRSAX509SelfSignedCACertificatePEM generates a x509 CA certificate PEM string. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: root_certificate_pem = "%[1]s"

func TLSRSAX509SelfSignedCertificatePEM

func TLSRSAX509SelfSignedCertificatePEM(t *testing.T, keyPem, commonName string) string

TLSRSAX509SelfSignedCertificatePEM generates a x509 certificate PEM string. Wrap with TLSPEMEscapeNewlines() to allow simple fmt.Sprintf() configurations such as: private_key_pem = "%[1]s"

func Test

func Test(ctx context.Context, t *testing.T, c resource.TestCase)

Test wraps resource.Test, initializing VCR if enabled

func ThirdRegion

func ThirdRegion() string

Types

type Func

type Func func(resourceName string) resource.ImportStateIdFunc

type ProviderFunc

type ProviderFunc func() *schema.Provider
var (
	DefaultProviderFunc ProviderFunc = func() *schema.Provider {
		return Provider
	}
)

func NamedProviderFunc

func NamedProviderFunc(name string, providers map[string]*schema.Provider) ProviderFunc

func RegionProviderFunc

func RegionProviderFunc(ctx context.Context, region string, providers *[]*schema.Provider) ProviderFunc

type ServiceErrorCheckFunc

type ServiceErrorCheckFunc func(*testing.T) resource.ErrorCheckFunc

type TestCheckWithProviderFunc

type TestCheckWithProviderFunc func(*terraform.State, *schema.Provider) error

type TestCheckWithRegionFunc

type TestCheckWithRegionFunc func(*terraform.State, string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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