Documentation ¶
Index ¶
- Constants
- Variables
- func AddAttrChecks(targetName string, checks []resource.TestCheckFunc, ...) []resource.TestCheckFunc
- func AddAttrChecksPrefix(targetName string, checks []resource.TestCheckFunc, ...) []resource.TestCheckFunc
- func AddAttrSetChecks(targetName string, checks []resource.TestCheckFunc, attrNames ...string) []resource.TestCheckFunc
- func AddAttrSetChecksPrefix(targetName string, checks []resource.TestCheckFunc, attrNames []string, ...) []resource.TestCheckFunc
- func AddNoAttrSetChecks(targetName string, checks []resource.TestCheckFunc, attrNames ...string) []resource.TestCheckFunc
- func CIDRBlockExpression() resource.CheckResourceAttrWithFunc
- func CheckClusterExistsHandlingRetry(projectID, clusterName string) error
- func CheckDestroyCluster(s *terraform.State) error
- func CheckDestroyFederatedDatabaseInstance(s *terraform.State) error
- func CheckDestroyNetworkPeering(s *terraform.State) error
- func CheckDestroyOrgInvitation(s *terraform.State) error
- func CheckDestroyProject(s *terraform.State) error
- func CheckDestroyProjectGov(s *terraform.State) error
- func CheckDestroySearchIndex(state *terraform.State) error
- func CheckDestroyStreamInstance(state *terraform.State) error
- func CheckDestroyTeam(s *terraform.State) error
- func CheckEARExists(resourceName string) resource.TestCheckFunc
- func CheckRSAndDS(resourceName string, dataSourceName, pluralDataSourceName *string, ...) resource.TestCheckFunc
- func ClusterDatasourceHcl(req *ClusterRequest) (configStr, clusterName, resourceName string, err error)
- func ClusterNameExecution(tb testing.TB) (projectID, clusterName string)
- func ClusterResourceHcl(req *ClusterRequest) (configStr, clusterName, resourceName string, err error)
- func ConfigAzapiProvider(subscriptionID, clientID, clientSecret, tenantID string) string
- func ConfigDataBaseUserWithOIDCAuthType(projectID, username, authType, databaseName, roleName string) string
- func ConfigDatabaseUserBasic(projectID, username, roleName, keyLabel, valueLabel string) string
- func ConfigDatabaseUserWithAWSIAMType(projectID, username, roleName, keyLabel, valueLabel string) string
- func ConfigDatabaseUserWithLDAPAuthType(projectID, username, roleName, keyLabel, valueLabel string) string
- func ConfigDatabaseUserWithLabels(projectID, username, roleName string, labels []admin.ComponentLabel) string
- func ConfigDatabaseUserWithRoles(projectID, username, password string, rolesArr []*admin.DatabaseUserRole) string
- func ConfigDatabaseUserWithScopes(projectID, username, password, roleName string, scopesArr []*admin.UserScope) string
- func ConfigDatabaseUserWithX509Type(projectID, username, x509Type, roleName, keyLabel, valueLabel string) string
- func ConfigEARAzureKeyVault(projectID string, azure *admin.AzureKeyVault, ...) string
- func ConfigGovProvider() string
- func ConfigProjectWithSettings(projectName, orgID, projectOwnerID string, value bool) string
- func ConfigServerlessInstance(projectID, name string, ignoreConnectionStrings bool, autoIndexing *bool, ...) string
- func Conn() *matlas.Client
- func ConnV2() *admin.APIClient
- func ConnV2UsingGov() *admin.APIClient
- func ConnV2UsingProxy(proxyPort *int) *admin.APIClient
- func ConvertToAzureKeyVaultEARAttrMap(az *admin.AzureKeyVault) map[string]string
- func DebugPlan() plancheck.PlanCheck
- func EARCheckResourceAttr(resourceName, prefix string, attrsMap map[string]string) resource.TestCheckFunc
- func EARDatasourceConfig() string
- func EARDestroy(s *terraform.State) error
- func EARImportStateIDFunc(resourceName string) resource.ImportStateIdFunc
- func ExistingClusterUsed() bool
- func ExternalProviders(versionAtlasProvider string) map[string]resource.ExternalProvider
- func ExternalProvidersOnlyAWS() map[string]resource.ExternalProvider
- func ExternalProvidersOnlyAzapi() map[string]resource.ExternalProvider
- func ExternalProvidersWithAWS(versionAtlasProvider string) map[string]resource.ExternalProvider
- func FormatToHCLLifecycleIgnore(keys ...string) string
- func FormatToHCLMap(m map[string]string, indent, varName string) string
- func GetProjectTeamsIDsWithPos(pos int) string
- func IDWithProjectIDClusterName(projectID, clusterName string) (string, error)
- func ImportStateClusterIDFunc(resourceName string) resource.ImportStateIdFunc
- func ImportStateIDFuncProjectIDClusterName(resourceName string) resource.ImportStateIdFunc
- func ImportStateProjectIDFunc(resourceName string) resource.ImportStateIdFunc
- func InCI() bool
- func InUnitTest() bool
- func IntGreatThan(value int) resource.CheckResourceAttrWithFunc
- func IsProjectNameOrID(expected string) resource.CheckResourceAttrWithFunc
- func JSONEquals(expected string) resource.CheckResourceAttrWithFunc
- func MatchesExpression(expr string) resource.CheckResourceAttrWithFunc
- func PreCheck(tb testing.TB)
- func PreCheckAtlasUsername(tb testing.TB)
- func PreCheckAtlasUsernames(tb testing.TB)
- func PreCheckAwsEnv(tb testing.TB)
- func PreCheckAwsEnvBasic(tb testing.TB)
- func PreCheckAwsEnvPrivateLinkEndpointService(tb testing.TB)
- func PreCheckAwsRegionCases(tb testing.TB)
- func PreCheckAzureExportBucket(tb testing.TB)
- func PreCheckBasic(tb testing.TB)
- func PreCheckBasicOwnerID(tb testing.TB)
- func PreCheckBasicSleep(tb testing.TB, clusterInfo *ClusterInfo, projectID, clusterName string) func()
- func PreCheckCert(tb testing.TB)
- func PreCheckCloudProviderAccessAzure(tb testing.TB)
- func PreCheckDataLakePipelineRun(tb testing.TB)
- func PreCheckDataLakePipelineRuns(tb testing.TB)
- func PreCheckEncryptionAtRestEnvAzure(tb testing.TB)
- func PreCheckEncryptionAtRestEnvAzureWithUpdate(tb testing.TB)
- func PreCheckEncryptionAtRestPrivateEndpoint(tb testing.TB)
- func PreCheckFederatedSettings(tb testing.TB)
- func PreCheckFederatedSettingsIdentityProvider(tb testing.TB)
- func PreCheckGPCEnv(tb testing.TB)
- func PreCheckGovBasic(tb testing.TB)
- func PreCheckLDAP(tb testing.TB)
- func PreCheckLDAPCert(tb testing.TB)
- func PreCheckPeeringEnvAWS(tb testing.TB)
- func PreCheckPeeringEnvAzure(tb testing.TB)
- func PreCheckPeeringEnvGCP(tb testing.TB)
- func PreCheckPreviewFlag(tb testing.TB)
- func PreCheckPrivateEndpoint(tb testing.TB)
- func PreCheckProjectTeamsIDsWithMinCount(tb testing.TB, minTeamsCount int)
- func PreCheckRegularCredsAreEmpty(tb testing.TB)
- func PreCheckS3Bucket(tb testing.TB)
- func PreCheckSTSAssumeRole(tb testing.TB)
- func ProjectID(tb testing.TB, name string) string
- func ProjectIDExecution(tb testing.TB) string
- func RandomClusterName() string
- func RandomEmail() string
- func RandomIAMRole() string
- func RandomIAMUser() string
- func RandomIP(a, b, c byte) string
- func RandomLDAPName() string
- func RandomName() string
- func RandomProjectName() string
- func RandomS3BucketName() string
- func SerialSleep(tb testing.TB)
- func SetupSharedResources() func()
- func SkipInUnitTest(tb testing.TB)
- func SkipTestForCI(tb testing.TB)
- func StreamInstanceConfig(projectID, instanceName, region, cloudProvider string) string
- func StreamInstanceWithStreamConfigConfig(projectID, instanceName, region, cloudProvider, configTier string) string
- func TestAccProviderV6FactoriesWithProxy(proxyPort *int) map[string]func() (tfprotov6.ProviderServer, error)
- func ToSnakeCase(str string) string
- type ClusterInfo
- type ClusterRequest
- type ReplicationSpecRequest
Constants ¶
const AwsProviderVersion = "5.1.0"
const (
// Provider name for single configuration testing
ProviderNameMongoDBAtlas = "mongodbatlas"
)
Variables ¶
var ( ClusterTagsMap1 = map[string]string{ "key": "key 1", "value": "value 1", } ClusterTagsMap2 = map[string]string{ "key": "key 2", "value": "value 2", } ClusterTagsMap3 = map[string]string{ "key": "key 3", "value": "value 3", } )
var (
ClusterAdvConfigOplogMinRetentionHours = "oplog_min_retention_hours"
)
var MongoDBClient *config.MongoDBClient
MongoDBClient is used to configure client required for Framework-based acceptance tests.
var TestAccProviderV6Factories map[string]func() (tfprotov6.ProviderServer, error)
TestAccProviderV6Factories is used in all tests for ProtoV6ProviderFactories.
Functions ¶
func AddAttrChecks ¶ added in v1.15.3
func AddAttrChecks(targetName string, checks []resource.TestCheckFunc, mapChecks map[string]string) []resource.TestCheckFunc
func AddAttrChecksPrefix ¶ added in v1.17.0
func AddAttrChecksPrefix(targetName string, checks []resource.TestCheckFunc, mapChecks map[string]string, prefix string, skipNames ...string) []resource.TestCheckFunc
func AddAttrSetChecks ¶ added in v1.15.3
func AddAttrSetChecks(targetName string, checks []resource.TestCheckFunc, attrNames ...string) []resource.TestCheckFunc
func AddAttrSetChecksPrefix ¶ added in v1.19.0
func AddAttrSetChecksPrefix(targetName string, checks []resource.TestCheckFunc, attrNames []string, prefix string) []resource.TestCheckFunc
func AddNoAttrSetChecks ¶ added in v1.16.0
func AddNoAttrSetChecks(targetName string, checks []resource.TestCheckFunc, attrNames ...string) []resource.TestCheckFunc
func CIDRBlockExpression ¶ added in v1.17.0
func CIDRBlockExpression() resource.CheckResourceAttrWithFunc
func CheckClusterExistsHandlingRetry ¶ added in v1.18.0
func CheckDestroyCluster ¶ added in v1.15.2
func CheckDestroyProject ¶
func CheckDestroyProjectGov ¶ added in v1.16.1
func CheckDestroySearchIndex ¶
func CheckDestroyTeam ¶
func CheckEARExists ¶ added in v1.19.0
func CheckEARExists(resourceName string) resource.TestCheckFunc
func CheckRSAndDS ¶ added in v1.19.0
func CheckRSAndDS(resourceName string, dataSourceName, pluralDataSourceName *string, attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc
CheckRSAndDS returns a check function that asserts a set of attributes (presence and values) in resource and data sources. If a plural data source name is provided, it will apply checks over first result
func ClusterDatasourceHcl ¶ added in v1.17.4
func ClusterDatasourceHcl(req *ClusterRequest) (configStr, clusterName, resourceName string, err error)
func ClusterNameExecution ¶ added in v1.16.0
ClusterNameExecution returns the name of a created cluster for the execution of the tests in the resource package. This function relies on using an execution project and returns its id. When `MONGODB_ATLAS_CLUSTER_NAME` and `MONGODB_ATLAS_PROJECT_ID` are defined it will be used instead of creating resources. This is useful for local execution but not intended for CI executions.
func ClusterResourceHcl ¶ added in v1.17.4
func ClusterResourceHcl(req *ClusterRequest) (configStr, clusterName, resourceName string, err error)
func ConfigAzapiProvider ¶ added in v1.19.0
configAzapiProvider creates a new azure/azapi provider with credentials explicit in config. This will authorize the provider for a client
func ConfigDataBaseUserWithOIDCAuthType ¶ added in v1.17.0
func ConfigDatabaseUserBasic ¶
func ConfigDatabaseUserWithLabels ¶
func ConfigDatabaseUserWithLabels(projectID, username, roleName string, labels []admin.ComponentLabel) string
func ConfigDatabaseUserWithRoles ¶
func ConfigDatabaseUserWithRoles(projectID, username, password string, rolesArr []*admin.DatabaseUserRole) string
func ConfigEARAzureKeyVault ¶ added in v1.19.0
func ConfigEARAzureKeyVault(projectID string, azure *admin.AzureKeyVault, useRequirePrivateNetworking, useDatasource bool) string
func ConfigGovProvider ¶ added in v1.16.1
func ConfigGovProvider() string
ConfigGovProvider creates provider using MONGODB_ATLAS_GOV_* env vars.
Remember to use PreCheckGovBasic when using this.
func ConfigProjectWithSettings ¶ added in v1.15.0
func ConfigServerlessInstance ¶ added in v1.16.0
func ConnV2UsingGov ¶ added in v1.16.1
func ConnV2UsingProxy ¶ added in v1.15.3
func ConvertToAzureKeyVaultEARAttrMap ¶ added in v1.19.0
func ConvertToAzureKeyVaultEARAttrMap(az *admin.AzureKeyVault) map[string]string
func EARCheckResourceAttr ¶ added in v1.19.0
func EARCheckResourceAttr(resourceName, prefix string, attrsMap map[string]string) resource.TestCheckFunc
func EARDatasourceConfig ¶ added in v1.19.0
func EARDatasourceConfig() string
func EARDestroy ¶ added in v1.19.0
func EARImportStateIDFunc ¶ added in v1.19.0
func EARImportStateIDFunc(resourceName string) resource.ImportStateIdFunc
func ExistingClusterUsed ¶ added in v1.15.2
func ExistingClusterUsed() bool
func ExternalProviders ¶ added in v1.15.0
func ExternalProviders(versionAtlasProvider string) map[string]resource.ExternalProvider
func ExternalProvidersOnlyAWS ¶ added in v1.15.0
func ExternalProvidersOnlyAWS() map[string]resource.ExternalProvider
func ExternalProvidersOnlyAzapi ¶ added in v1.19.0
func ExternalProvidersOnlyAzapi() map[string]resource.ExternalProvider
func ExternalProvidersWithAWS ¶ added in v1.15.0
func ExternalProvidersWithAWS(versionAtlasProvider string) map[string]resource.ExternalProvider
func FormatToHCLLifecycleIgnore ¶ added in v1.16.0
func FormatToHCLMap ¶ added in v1.16.0
func GetProjectTeamsIDsWithPos ¶ added in v1.15.2
func IDWithProjectIDClusterName ¶ added in v1.20.0
func ImportStateClusterIDFunc ¶
func ImportStateClusterIDFunc(resourceName string) resource.ImportStateIdFunc
func ImportStateIDFuncProjectIDClusterName ¶ added in v1.20.0
func ImportStateIDFuncProjectIDClusterName(resourceName string) resource.ImportStateIdFunc
func ImportStateProjectIDFunc ¶
func ImportStateProjectIDFunc(resourceName string) resource.ImportStateIdFunc
func InUnitTest ¶ added in v1.15.2
func InUnitTest() bool
func IntGreatThan ¶
func IntGreatThan(value int) resource.CheckResourceAttrWithFunc
func IsProjectNameOrID ¶ added in v1.21.4
func IsProjectNameOrID(expected string) resource.CheckResourceAttrWithFunc
IsProjectNameOrID accepts a project id or name and checks if the input project id matches the expected project
func JSONEquals ¶
func JSONEquals(expected string) resource.CheckResourceAttrWithFunc
func MatchesExpression ¶
func MatchesExpression(expr string) resource.CheckResourceAttrWithFunc
func PreCheck ¶
PreCheck checks common Atlas environment variables and MONGODB_ATLAS_PROJECT_ID. Deprecated: it should not be used as MONGODB_ATLAS_PROJECT_ID is not intended to be used in CI. Use PreCheckBasic instead.
func PreCheckAtlasUsername ¶
func PreCheckAtlasUsernames ¶ added in v1.21.1
func PreCheckAwsEnv ¶
func PreCheckAwsEnvBasic ¶ added in v1.16.0
func PreCheckAwsEnvPrivateLinkEndpointService ¶ added in v1.16.1
func PreCheckAwsRegionCases ¶ added in v1.17.4
func PreCheckAzureExportBucket ¶ added in v1.18.0
func PreCheckBasic ¶
func PreCheckBasicOwnerID ¶
func PreCheckBasicSleep ¶ added in v1.21.2
func PreCheckBasicSleep(tb testing.TB, clusterInfo *ClusterInfo, projectID, clusterName string) func()
PreCheckBasicSleep is a helper function to call SerialSleep, see its help for more info. Some examples of use are when the test is calling ProjectIDExecution or GetClusterInfo to create clusters.
func PreCheckCert ¶ added in v1.15.1
func PreCheckEncryptionAtRestEnvAzureWithUpdate ¶ added in v1.19.0
func PreCheckEncryptionAtRestPrivateEndpoint ¶ added in v1.19.0
func PreCheckFederatedSettingsIdentityProvider ¶ added in v1.16.1
func PreCheckGPCEnv ¶
func PreCheckGovBasic ¶ added in v1.16.0
func PreCheckLDAP ¶
func PreCheckLDAPCert ¶ added in v1.15.2
func PreCheckPeeringEnvAWS ¶
func PreCheckPeeringEnvAzure ¶
func PreCheckPeeringEnvGCP ¶
func PreCheckPreviewFlag ¶ added in v1.15.2
PreCheckPreviewFlag is used for resources not yet in GA
func PreCheckPrivateEndpoint ¶ added in v1.15.2
func PreCheckProjectTeamsIDsWithMinCount ¶ added in v1.15.2
func PreCheckS3Bucket ¶ added in v1.15.0
func PreCheckSTSAssumeRole ¶
func ProjectID ¶ added in v1.15.3
ProjectID returns the id for a project name. When `MONGODB_ATLAS_PROJECT_ID` is defined, it is used instead of creating a project. This is useful for local execution but not intended for CI executions.
func ProjectIDExecution ¶ added in v1.15.2
ProjectIDExecution returns a project id created for the execution of the tests in the resource package. Even if a GH test group is run, every resource/package will create its own project, not a shared project for all the test group. When `MONGODB_ATLAS_PROJECT_ID` is defined, it is used instead of creating a project. This is useful for local execution but not intended for CI executions.
func RandomClusterName ¶ added in v1.15.2
func RandomClusterName() string
func RandomEmail ¶ added in v1.15.2
func RandomEmail() string
func RandomIAMRole ¶ added in v1.15.2
func RandomIAMRole() string
func RandomIAMUser ¶ added in v1.15.2
func RandomIAMUser() string
func RandomLDAPName ¶ added in v1.15.2
func RandomLDAPName() string
func RandomName ¶ added in v1.15.2
func RandomName() string
func RandomProjectName ¶ added in v1.15.2
func RandomProjectName() string
func RandomS3BucketName ¶ added in v1.16.0
func RandomS3BucketName() string
func SerialSleep ¶ added in v1.21.2
SerialSleep waits a few seconds the first time so the first cluster in a project is not created concurrently, see HELP-65223. This must be called once the test is marked as parallel, e.g. in PreCheck inside Terraform tests.
func SetupSharedResources ¶ added in v1.15.2
func SetupSharedResources() func()
SetupSharedResources must be called from TestMain test package in order to use ProjectIDExecution. It returns the cleanup function that must be called at the end of TestMain.
func SkipInUnitTest ¶ added in v1.15.2
SkipInUnitTest allows skipping a test entirely when TF_ACC=1 is not defined. This can be useful for acceptance tests that define logic prior to resource.Test/resource.ParallelTest functions as this code would always be run.
func SkipTestForCI ¶
SkipTestForCI is added to tests that cannot run as part of CI, e.g. in Github actions.
func StreamInstanceConfig ¶
func StreamInstanceWithStreamConfigConfig ¶ added in v1.15.2
func TestAccProviderV6FactoriesWithProxy ¶ added in v1.15.3
func TestAccProviderV6FactoriesWithProxy(proxyPort *int) map[string]func() (tfprotov6.ProviderServer, error)
func ToSnakeCase ¶ added in v1.17.4
Types ¶
type ClusterInfo ¶
type ClusterInfo struct { ProjectID string Name string ResourceName string TerraformNameRef string TerraformStr string }
func GetClusterInfo ¶
func GetClusterInfo(tb testing.TB, req *ClusterRequest) ClusterInfo
GetClusterInfo is used to obtain a project and cluster configuration resource. When `MONGODB_ATLAS_CLUSTER_NAME` and `MONGODB_ATLAS_PROJECT_ID` are defined, a data source is created instead. This is useful for local execution but not intended for CI executions. Clusters will be created in project ProjectIDExecution or in req.ProjectID which can be both a direct id, e.g., `664610ec80cc36255e634074` or a config reference `mongodbatlas_project.test.id`.
type ClusterRequest ¶ added in v1.15.2
type ClusterRequest struct { Tags map[string]string ProjectID string ResourceSuffix string AdvancedConfiguration map[string]any ResourceDependencyName string ClusterName string MongoDBMajorVersion string ReplicationSpecs []ReplicationSpecRequest DiskSizeGb int CloudBackup bool Geosharded bool RetainBackupsEnabled bool PitEnabled bool }
ClusterRequest contains configuration for a cluster where all fields are optional and AddDefaults is used for required fields. Used together with GetClusterInfo which will set ProjectID if it is unset.
func (*ClusterRequest) AddDefaults ¶ added in v1.17.4
func (r *ClusterRequest) AddDefaults()
AddDefaults ensures the required fields are populated to generate a resource.
func (*ClusterRequest) ClusterType ¶ added in v1.17.4
func (r *ClusterRequest) ClusterType() string
type ReplicationSpecRequest ¶ added in v1.17.4
type ReplicationSpecRequest struct { ZoneName string Region string InstanceSize string ProviderName string EbsVolumeType string ExtraRegionConfigs []ReplicationSpecRequest NodeCount int NodeCountReadOnly int Priority int AutoScalingDiskGbEnabled bool }
ReplicationSpecRequest can be used to customize the ReplicationSpecs of a Cluster. No fields are required. Use `ExtraRegionConfigs` to specify multiple region configs.
func (*ReplicationSpecRequest) AddDefaults ¶ added in v1.17.4
func (r *ReplicationSpecRequest) AddDefaults()
func (*ReplicationSpecRequest) AllRegionConfigs ¶ added in v1.17.4
func (r *ReplicationSpecRequest) AllRegionConfigs() []admin.CloudRegionConfig20240805
Source Files ¶
- advanced_cluster.go
- atlas.go
- attribute_checks.go
- cluster.go
- config_cluster.go
- config_formatter.go
- database_user.go
- encryption_at_rest.go
- factory.go
- federated.go
- import_state.go
- name.go
- network_peering.go
- org.go
- plan_check.go
- pre_check.go
- project.go
- provider.go
- search_index.go
- serverless.go
- shared_resource.go
- skip.go
- stream_instance.go
- team.go