Skip to content

Commit

Permalink
[WIP] Allow setting endpoint for autoscaling
Browse files Browse the repository at this point in the history
Adding support for setting user defined end-point
Github issue hashicorp#4967
  • Loading branch information
bardielle committed Jun 24, 2018
1 parent 7baa704 commit 1ae7134
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type Config struct {
DeviceFarmEndpoint string
Ec2Endpoint string
EcsEndpoint string
AutoscalingEndpoint string
EcrEndpoint string
EfsEndpoint string
EsEndpoint string
Expand Down Expand Up @@ -392,6 +393,7 @@ func (c *Config) Client() (interface{}, error) {
awsCwlSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.CloudWatchLogsEndpoint)})
awsDynamoSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.DynamoDBEndpoint)})
awsEc2Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.Ec2Endpoint)})
awsAutoscalingSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.AutoscalingEndpoint)})
awsEcrSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.EcrEndpoint)})
awsEcsSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.EcsEndpoint)})
awsEfsSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.EfsEndpoint)})
Expand Down Expand Up @@ -458,7 +460,7 @@ func (c *Config) Client() (interface{}, error) {
client.acmpcaconn = acmpca.New(sess)
client.apigateway = apigateway.New(awsApigatewaySess)
client.appautoscalingconn = applicationautoscaling.New(sess)
client.autoscalingconn = autoscaling.New(sess)
client.autoscalingconn = autoscaling.New(awsAutoscalingSess)
client.cloud9conn = cloud9.New(sess)
client.cfconn = cloudformation.New(awsCfSess)
client.cloudfrontconn = cloudfront.New(sess)
Expand Down
11 changes: 11 additions & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ func init() {

"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",
Expand Down Expand Up @@ -812,6 +814,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
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)
Expand Down Expand Up @@ -947,6 +950,13 @@ func endpointsSchema() *schema.Schema {
Description: descriptions["ec2_endpoint"],
},

"autoscaling": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["autoscaling_endpoint"],
},

"ecr": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1058,6 +1068,7 @@ func endpointsToHash(v interface{}) int {
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["kinesis"].(string)))
Expand Down
4 changes: 4 additions & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ Nested `endpoints` block supports the following:
URL constructed from the `region`. It's typically used to connect to
custom EC2 endpoints.

* `autoscaling` - (Optional) Use this to override the default endpoint
URL constructed from the `region`. It's typically used to connect to
custom Autoscaling endpoints.

* `ecr` - (Optional) Use this to override the default endpoint
URL constructed from the `region`. It's typically used to connect to
custom ECR endpoints.
Expand Down

0 comments on commit 1ae7134

Please sign in to comment.