diff --git a/aws/config.go b/aws/config.go index 871bf571f63f..41cbaf4fcd89 100644 --- a/aws/config.go +++ b/aws/config.go @@ -143,38 +143,8 @@ type Config struct { AllowedAccountIds []string ForbiddenAccountIds []string - AcmEndpoint string - ApigatewayEndpoint string - CloudFormationEndpoint string - CloudWatchEndpoint string - CloudWatchEventsEndpoint string - CloudWatchLogsEndpoint string - DynamoDBEndpoint string - DeviceFarmEndpoint string - Ec2Endpoint string - EcsEndpoint string - AutoscalingEndpoint string - EcrEndpoint string - EfsEndpoint string - EsEndpoint string - ElbEndpoint string - FirehoseEndpoint string - IamEndpoint string - KinesisEndpoint string - KinesisAnalyticsEndpoint string - KmsEndpoint string - LambdaEndpoint string - RdsEndpoint string - RedshiftEndpoint string - R53Endpoint string - S3Endpoint string - S3ControlEndpoint string - SesEndpoint string - SnsEndpoint string - SqsEndpoint string - StsEndpoint string - SsmEndpoint string - Insecure bool + Endpoints map[string]string + Insecure bool SkipCredsValidation bool SkipGetEC2Platforms bool @@ -323,7 +293,7 @@ func (c *Config) Client() (interface{}, error) { AssumeRoleSessionName: c.AssumeRoleSessionName, CredsFilename: c.CredsFilename, DebugLogging: logging.IsDebugOrHigher(), - IamEndpoint: c.IamEndpoint, + IamEndpoint: c.Endpoints["iam"], Insecure: c.Insecure, MaxRetries: c.MaxRetries, Profile: c.Profile, @@ -332,7 +302,7 @@ func (c *Config) Client() (interface{}, error) { SkipCredsValidation: c.SkipCredsValidation, SkipMetadataApiCheck: c.SkipMetadataApiCheck, SkipRequestingAccountId: c.SkipRequestingAccountId, - StsEndpoint: c.StsEndpoint, + StsEndpoint: c.Endpoints["sts"], Token: c.Token, UserAgentProducts: []*awsbase.UserAgentProduct{ {Name: "APN", Version: "1.0"}, @@ -356,121 +326,129 @@ func (c *Config) Client() (interface{}, error) { client := &AWSClient{ accountid: accountID, - acmconn: acm.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.AcmEndpoint)})), - acmpcaconn: acmpca.New(sess), - apigateway: apigateway.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.ApigatewayEndpoint)})), - apigatewayv2conn: apigatewayv2.New(sess), - appautoscalingconn: applicationautoscaling.New(sess), - appmeshconn: appmesh.New(sess), - appsyncconn: appsync.New(sess), - athenaconn: athena.New(sess), - autoscalingconn: autoscaling.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.AutoscalingEndpoint)})), - backupconn: backup.New(sess), - batchconn: batch.New(sess), - budgetconn: budgets.New(sess), - cfconn: cloudformation.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.CloudFormationEndpoint)})), - cloud9conn: cloud9.New(sess), - cloudfrontconn: cloudfront.New(sess), - cloudhsmv2conn: cloudhsmv2.New(sess), - cloudsearchconn: cloudsearch.New(sess), - cloudtrailconn: cloudtrail.New(sess), - cloudwatchconn: cloudwatch.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.CloudWatchEndpoint)})), - cloudwatcheventsconn: cloudwatchevents.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.CloudWatchEventsEndpoint)})), - cloudwatchlogsconn: cloudwatchlogs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.CloudWatchLogsEndpoint)})), - codebuildconn: codebuild.New(sess), - codecommitconn: codecommit.New(sess), - codedeployconn: codedeploy.New(sess), - codepipelineconn: codepipeline.New(sess), - cognitoconn: cognitoidentity.New(sess), - cognitoidpconn: cognitoidentityprovider.New(sess), - configconn: configservice.New(sess), - costandusagereportconn: costandusagereportservice.New(sess), - datapipelineconn: datapipeline.New(sess), - datasyncconn: datasync.New(sess), - daxconn: dax.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.DynamoDBEndpoint)})), - devicefarmconn: devicefarm.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.DeviceFarmEndpoint)})), - dlmconn: dlm.New(sess), - dmsconn: databasemigrationservice.New(sess), - docdbconn: docdb.New(sess), - dsconn: directoryservice.New(sess), - dxconn: directconnect.New(sess), - dynamodbconn: dynamodb.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.DynamoDBEndpoint)})), - ec2conn: ec2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Ec2Endpoint)})), - ecrconn: ecr.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.EcrEndpoint)})), - ecsconn: ecs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.EcsEndpoint)})), - efsconn: efs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.EfsEndpoint)})), - eksconn: eks.New(sess), - elasticacheconn: elasticache.New(sess), - elasticbeanstalkconn: elasticbeanstalk.New(sess), - elastictranscoderconn: elastictranscoder.New(sess), - elbconn: elb.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})), - elbv2conn: elbv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})), - emrconn: emr.New(sess), - esconn: elasticsearch.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.EsEndpoint)})), - firehoseconn: firehose.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.FirehoseEndpoint)})), - fmsconn: fms.New(sess), - fsxconn: fsx.New(sess), - gameliftconn: gamelift.New(sess), - glacierconn: glacier.New(sess), - globalacceleratorconn: globalaccelerator.New(sess), - glueconn: glue.New(sess), - guarddutyconn: guardduty.New(sess), - iamconn: iam.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.IamEndpoint)})), - inspectorconn: inspector.New(sess), - iotconn: iot.New(sess), - kafkaconn: kafka.New(sess), - kinesisanalyticsconn: kinesisanalytics.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.KinesisAnalyticsEndpoint)})), - kinesisanalyticsv2conn: kinesisanalyticsv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.KinesisAnalyticsEndpoint)})), - kinesisconn: kinesis.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.KinesisEndpoint)})), - kmsconn: kms.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.KmsEndpoint)})), - lambdaconn: lambda.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.LambdaEndpoint)})), - lexmodelconn: lexmodelbuildingservice.New(sess), - licensemanagerconn: licensemanager.New(sess), - lightsailconn: lightsail.New(sess), - macieconn: macie.New(sess), - mediaconnectconn: mediaconnect.New(sess), - mediaconvertconn: mediaconvert.New(sess), - medialiveconn: medialive.New(sess), - mediapackageconn: mediapackage.New(sess), - mediastoreconn: mediastore.New(sess), - mediastoredataconn: mediastoredata.New(sess), - mqconn: mq.New(sess), - neptuneconn: neptune.New(sess), - opsworksconn: opsworks.New(sess), - organizationsconn: organizations.New(sess), + acmconn: acm.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["acm"])})), + acmpcaconn: acmpca.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["acmpca"])})), + apigateway: apigateway.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["apigateway"])})), + apigatewayv2conn: apigatewayv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["apigateway"])})), + appautoscalingconn: applicationautoscaling.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["applicationautoscaling"])})), + appmeshconn: appmesh.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appmesh"])})), + appsyncconn: appsync.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appsync"])})), + athenaconn: athena.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["athena"])})), + autoscalingconn: autoscaling.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["autoscaling"])})), + backupconn: backup.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["backup"])})), + batchconn: batch.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["batch"])})), + budgetconn: budgets.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["budgets"])})), + cfconn: cloudformation.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudformation"])})), + cloud9conn: cloud9.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloud9"])})), + cloudfrontconn: cloudfront.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudfront"])})), + cloudhsmv2conn: cloudhsmv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudhsm"])})), + cloudsearchconn: cloudsearch.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudsearch"])})), + cloudtrailconn: cloudtrail.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudtrail"])})), + cloudwatchconn: cloudwatch.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudwatch"])})), + cloudwatcheventsconn: cloudwatchevents.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudwatchevents"])})), + cloudwatchlogsconn: cloudwatchlogs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cloudwatchlogs"])})), + codebuildconn: codebuild.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["codebuild"])})), + codecommitconn: codecommit.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["codecommit"])})), + codedeployconn: codedeploy.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["codedeploy"])})), + codepipelineconn: codepipeline.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["codepipeline"])})), + cognitoconn: cognitoidentity.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cognitoidentity"])})), + cognitoidpconn: cognitoidentityprovider.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cognitoidentityprovider"])})), + configconn: configservice.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["configservice"])})), + costandusagereportconn: costandusagereportservice.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["cur"])})), + datapipelineconn: datapipeline.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["datapipeline"])})), + datasyncconn: datasync.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["datasync"])})), + daxconn: dax.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["dax"])})), + devicefarmconn: devicefarm.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["devicefarm"])})), + dlmconn: dlm.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["dlm"])})), + dmsconn: databasemigrationservice.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["dms"])})), + docdbconn: docdb.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["docdb"])})), + dsconn: directoryservice.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ds"])})), + dxconn: directconnect.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["directconnect"])})), + dynamodbconn: dynamodb.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["dynamodb"])})), + ec2conn: ec2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ec2"])})), + ecrconn: ecr.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ecr"])})), + ecsconn: ecs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ecs"])})), + efsconn: efs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["efs"])})), + eksconn: eks.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["eks"])})), + elasticacheconn: elasticache.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["elasticache"])})), + elasticbeanstalkconn: elasticbeanstalk.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["elasticbeanstalk"])})), + elastictranscoderconn: elastictranscoder.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["elastictranscoder"])})), + elbconn: elb.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["elb"])})), + elbv2conn: elbv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["elb"])})), + emrconn: emr.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["emr"])})), + esconn: elasticsearch.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["es"])})), + firehoseconn: firehose.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["firehose"])})), + fmsconn: fms.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["fms"])})), + fsxconn: fsx.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["fsx"])})), + gameliftconn: gamelift.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["gamelift"])})), + glacierconn: glacier.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["glacier"])})), + globalacceleratorconn: globalaccelerator.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["globalaccelerator"])})), + glueconn: glue.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["glue"])})), + guarddutyconn: guardduty.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["guardduty"])})), + iamconn: iam.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["iam"])})), + inspectorconn: inspector.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["inspector"])})), + iotconn: iot.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["iot"])})), + kafkaconn: kafka.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kafka"])})), + kinesisanalyticsconn: kinesisanalytics.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kinesisanalytics"])})), + kinesisanalyticsv2conn: kinesisanalyticsv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kinesisanalytics"])})), + kinesisconn: kinesis.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kinesis"])})), + kmsconn: kms.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kms"])})), + lambdaconn: lambda.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["lambda"])})), + lexmodelconn: lexmodelbuildingservice.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["lexmodels"])})), + licensemanagerconn: licensemanager.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["licensemanager"])})), + lightsailconn: lightsail.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["lightsail"])})), + macieconn: macie.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["macie"])})), + mediaconnectconn: mediaconnect.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mediaconnect"])})), + mediaconvertconn: mediaconvert.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mediaconvert"])})), + medialiveconn: medialive.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["medialive"])})), + mediapackageconn: mediapackage.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mediapackage"])})), + mediastoreconn: mediastore.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mediastore"])})), + mediastoredataconn: mediastoredata.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mediastoredata"])})), + mqconn: mq.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["mq"])})), + neptuneconn: neptune.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["neptune"])})), + opsworksconn: opsworks.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["opsworks"])})), + organizationsconn: organizations.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["organizations"])})), partition: partition, - pinpointconn: pinpoint.New(sess), - pricingconn: pricing.New(sess), - r53conn: route53.New(sess.Copy(&aws.Config{Region: aws.String("us-east-1"), Endpoint: aws.String(c.R53Endpoint)})), - ramconn: ram.New(sess), - rdsconn: rds.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.RdsEndpoint)})), - redshiftconn: redshift.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.RedshiftEndpoint)})), + pinpointconn: pinpoint.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["pinpoint"])})), + pricingconn: pricing.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["pricing"])})), + r53conn: route53.New(sess.Copy(&aws.Config{Region: aws.String("us-east-1"), Endpoint: aws.String(c.Endpoints["route53"])})), + ramconn: ram.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ram"])})), + rdsconn: rds.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["rds"])})), + redshiftconn: redshift.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["redshift"])})), region: c.Region, - resourcegroupsconn: resourcegroups.New(sess), - route53resolverconn: route53resolver.New(sess), - s3conn: s3.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.S3Endpoint), S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle)})), - s3controlconn: s3control.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.S3ControlEndpoint)})), - sagemakerconn: sagemaker.New(sess), - scconn: servicecatalog.New(sess), - sdconn: servicediscovery.New(sess), - secretsmanagerconn: secretsmanager.New(sess), - securityhubconn: securityhub.New(sess), - serverlessapplicationrepositoryconn: serverlessapplicationrepository.New(sess), - sesConn: ses.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.SesEndpoint)})), - sfnconn: sfn.New(sess), - shieldconn: shield.New(sess), - simpledbconn: simpledb.New(sess), - snsconn: sns.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.SnsEndpoint)})), - sqsconn: sqs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.SqsEndpoint)})), - ssmconn: ssm.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.SsmEndpoint)})), - storagegatewayconn: storagegateway.New(sess), - stsconn: sts.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.StsEndpoint)})), - swfconn: swf.New(sess), - transferconn: transfer.New(sess), - wafconn: waf.New(sess), - wafregionalconn: wafregional.New(sess), - worklinkconn: worklink.New(sess), - workspacesconn: workspaces.New(sess), + resourcegroupsconn: resourcegroups.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["resourcegroups"])})), + route53resolverconn: route53resolver.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["route53resolver"])})), + s3conn: s3.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["s3"]), S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle)})), + s3controlconn: s3control.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["s3control"])})), + sagemakerconn: sagemaker.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sagemaker"])})), + scconn: servicecatalog.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["servicecatalog"])})), + sdconn: servicediscovery.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["servicediscovery"])})), + secretsmanagerconn: secretsmanager.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["secretsmanager"])})), + securityhubconn: securityhub.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["securityhub"])})), + serverlessapplicationrepositoryconn: serverlessapplicationrepository.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["serverlessrepo"])})), + sesConn: ses.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ses"])})), + sfnconn: sfn.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["stepfunctions"])})), + shieldconn: shield.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["shield"])})), + simpledbconn: simpledb.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sdb"])})), + snsconn: sns.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sns"])})), + sqsconn: sqs.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sqs"])})), + ssmconn: ssm.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["ssm"])})), + storagegatewayconn: storagegateway.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["storagegateway"])})), + stsconn: sts.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sts"])})), + swfconn: swf.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["swf"])})), + transferconn: transfer.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["transfer"])})), + wafconn: waf.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["waf"])})), + wafregionalconn: wafregional.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["wafregional"])})), + worklinkconn: worklink.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["worklink"])})), + workspacesconn: workspaces.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["workspaces"])})), + } + + // Handle deprecated endpoint configurations + if c.Endpoints["kinesis_analytics"] != "" { + client.kinesisanalyticsconn = kinesisanalytics.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kinesis_analytics"])})) + } + if c.Endpoints["r53"] != "" { + client.r53conn = route53.New(sess.Copy(&aws.Config{Region: aws.String("us-east-1"), Endpoint: aws.String(c.Endpoints["r53"])})) } // Workaround for https://github.com/aws/aws-sdk-go/issues/1376 diff --git a/aws/provider.go b/aws/provider.go index 2d3cf404c906..93cd3dfdb6f8 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -1,11 +1,8 @@ package aws import ( - "bytes" - "fmt" "log" - "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/mutexkv" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" @@ -780,6 +777,7 @@ func Provider() terraform.ResourceProvider { } var descriptions map[string]string +var endpointServiceNames []string func init() { descriptions = map[string]string{ @@ -805,59 +803,7 @@ func init() { "being executed. If the API request still fails, an error is\n" + "thrown.", - "apigateway_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "cloudformation_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "cloudwatch_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "cloudwatchevents_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "cloudwatchlogs_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "devicefarm_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "dynamodb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + - "It's typically used to connect to dynamodb-local.", - - "firehose_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "kinesis_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + - "It's typically used to connect to kinesalite.", - - "kinesis_analytics_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "kms_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "iam_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "lambda_endpoint": "Use this to override the default endpoint URL constructed from the `region`\n", - - "ec2_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "autoscaling_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "efs_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "elb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "es_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "rds_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "redshift_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "s3_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "s3control_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "ses_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "sns_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "sqs_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", - - "ssm_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n", + "endpoint": "Use this to override the default service endpoint URL", "insecure": "Explicitly allow the provider to perform \"insecure\" SSL requests. If omitted," + "default value is `false`", @@ -894,6 +840,121 @@ func init() { " this policy to grant further permissions that are in excess to those of the, " + " role that is being assumed.", } + + endpointServiceNames = []string{ + "acm", + "acmpca", + "apigateway", + "applicationautoscaling", + "appmesh", + "appsync", + "athena", + "autoscaling", + "backup", + "batch", + "budgets", + "cloud9", + "cloudformation", + "cloudfront", + "cloudhsm", + "cloudsearch", + "cloudtrail", + "cloudwatch", + "cloudwatchevents", + "cloudwatchlogs", + "codebuild", + "codecommit", + "codedeploy", + "codepipeline", + "cognitoidentity", + "cognitoidp", + "configservice", + "cur", + "datapipeline", + "datasync", + "dax", + "devicefarm", + "directconnect", + "dlm", + "dms", + "docdb", + "ds", + "dynamodb", + "ec2", + "ecr", + "ecs", + "efs", + "eks", + "elasticache", + "elasticbeanstalk", + "elastictranscoder", + "elb", + "emr", + "es", + "firehose", + "fms", + "fsx", + "gamelift", + "glacier", + "globalaccelerator", + "glue", + "guardduty", + "iam", + "inspector", + "iot", + "kafka", + "kinesis_analytics", + "kinesis", + "kinesisanalytics", + "kms", + "lambda", + "lexmodels", + "licensemanager", + "lightsail", + "macie", + "mediaconnect", + "mediaconvert", + "medialive", + "mediapackage", + "mediastore", + "mediastoredata", + "mq", + "neptune", + "opsworks", + "organizations", + "pinpoint", + "pricing", + "r53", + "ram", + "rds", + "redshift", + "resourcegroups", + "route53", + "route53resolver", + "s3", + "s3control", + "sagemaker", + "sdb", + "secretsmanager", + "securityhub", + "serverlessrepo", + "servicecatalog", + "servicediscovery", + "ses", + "shield", + "sns", + "sqs", + "ssm", + "stepfunctions", + "storagegateway", + "sts", + "swf", + "transfer", + "waf", + "wafregional", + "worklink", + "workspaces", + } } func providerConfigure(d *schema.ResourceData) (interface{}, error) { @@ -941,37 +1002,9 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { for _, endpointsSetI := range endpointsSet.List() { endpoints := endpointsSetI.(map[string]interface{}) - config.AcmEndpoint = endpoints["acm"].(string) - config.ApigatewayEndpoint = endpoints["apigateway"].(string) - config.CloudFormationEndpoint = endpoints["cloudformation"].(string) - config.CloudWatchEndpoint = endpoints["cloudwatch"].(string) - config.CloudWatchEventsEndpoint = endpoints["cloudwatchevents"].(string) - config.CloudWatchLogsEndpoint = endpoints["cloudwatchlogs"].(string) - config.DeviceFarmEndpoint = endpoints["devicefarm"].(string) - config.DynamoDBEndpoint = endpoints["dynamodb"].(string) - config.Ec2Endpoint = endpoints["ec2"].(string) - config.AutoscalingEndpoint = endpoints["autoscaling"].(string) - config.EcrEndpoint = endpoints["ecr"].(string) - config.EcsEndpoint = endpoints["ecs"].(string) - config.EfsEndpoint = endpoints["efs"].(string) - config.ElbEndpoint = endpoints["elb"].(string) - config.EsEndpoint = endpoints["es"].(string) - config.FirehoseEndpoint = endpoints["firehose"].(string) - config.IamEndpoint = endpoints["iam"].(string) - config.KinesisEndpoint = endpoints["kinesis"].(string) - config.KinesisAnalyticsEndpoint = endpoints["kinesis_analytics"].(string) - config.KmsEndpoint = endpoints["kms"].(string) - config.LambdaEndpoint = endpoints["lambda"].(string) - config.R53Endpoint = endpoints["r53"].(string) - config.RdsEndpoint = endpoints["rds"].(string) - config.RedshiftEndpoint = endpoints["redshift"].(string) - config.S3Endpoint = endpoints["s3"].(string) - config.S3ControlEndpoint = endpoints["s3control"].(string) - config.SesEndpoint = endpoints["ses"].(string) - config.SnsEndpoint = endpoints["sns"].(string) - config.SqsEndpoint = endpoints["sqs"].(string) - config.StsEndpoint = endpoints["sts"].(string) - config.SsmEndpoint = endpoints["ssm"].(string) + for _, endpointServiceName := range endpointServiceNames { + config.Endpoints[endpointServiceName] = endpoints[endpointServiceName].(string) + } } if v, ok := d.GetOk("allowed_account_ids"); ok { @@ -1028,234 +1061,26 @@ func assumeRoleSchema() *schema.Schema { } func endpointsSchema() *schema.Schema { + endpointsAttributes := make(map[string]*schema.Schema) + + for _, endpointServiceName := range endpointServiceNames { + endpointsAttributes[endpointServiceName] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["endpoint"], + } + } + + // Since the endpoints attribute is a TypeSet we cannot use ConflictsWith + endpointsAttributes["kinesis_analytics"].Deprecated = "use `endpoints` configuration block `kinesisanalytics` argument instead" + endpointsAttributes["r53"].Deprecated = "use `endpoints` configuration block `route53` argument instead" + return &schema.Schema{ Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "acm": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["acm_endpoint"], - }, - "apigateway": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["apigateway_endpoint"], - }, - "cloudwatch": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["cloudwatch_endpoint"], - }, - "cloudwatchevents": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["cloudwatchevents_endpoint"], - }, - "cloudwatchlogs": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["cloudwatchlogs_endpoint"], - }, - "cloudformation": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["cloudformation_endpoint"], - }, - "devicefarm": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["devicefarm_endpoint"], - }, - "dynamodb": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["dynamodb_endpoint"], - }, - "iam": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["iam_endpoint"], - }, - - "ec2": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["ec2_endpoint"], - }, - - "autoscaling": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["autoscaling_endpoint"], - }, - - "ecr": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["ecr_endpoint"], - }, - - "ecs": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["ecs_endpoint"], - }, - - "efs": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["efs_endpoint"], - }, - - "elb": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["elb_endpoint"], - }, - "es": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["es_endpoint"], - }, - "firehose": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["firehose_endpoint"], - }, - "kinesis": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["kinesis_endpoint"], - }, - "kinesis_analytics": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["kinesis_analytics_endpoint"], - }, - "kms": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["kms_endpoint"], - }, - "lambda": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["lambda_endpoint"], - }, - "r53": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["r53_endpoint"], - }, - "rds": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["rds_endpoint"], - }, - "redshift": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["redshift_endpoint"], - }, - "s3": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["s3_endpoint"], - }, - "s3control": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["s3control_endpoint"], - }, - "ses": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["ses_endpoint"], - }, - "sns": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["sns_endpoint"], - }, - "sqs": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["sqs_endpoint"], - }, - "sts": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["sts_endpoint"], - }, - "ssm": { - Type: schema.TypeString, - Optional: true, - Default: "", - Description: descriptions["ssm_endpoint"], - }, - }, + Schema: endpointsAttributes, }, - Set: endpointsToHash, } } - -func endpointsToHash(v interface{}) int { - var buf bytes.Buffer - m := v.(map[string]interface{}) - buf.WriteString(fmt.Sprintf("%s-", m["apigateway"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["cloudwatch"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["cloudwatchevents"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["cloudwatchlogs"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["cloudformation"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["devicefarm"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["dynamodb"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["iam"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["ec2"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["autoscaling"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["efs"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["elb"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["firehose"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["kinesis"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["kms"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["lambda"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["rds"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["redshift"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["s3"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["ses"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["sns"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["sqs"].(string))) - - return hashcode.String(buf.String()) -}