Skip to content

Commit

Permalink
Allow setting endpoint for EFS
Browse files Browse the repository at this point in the history
Adding support for setting user defined end-point
  • Loading branch information
joseph-stratoscale committed Jun 1, 2018
1 parent 3cf12ce commit d53b1c2
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 @@ -124,6 +124,7 @@ type Config struct {
Ec2Endpoint string
EcsEndpoint string
EcrEndpoint string
EfsEndpoint string
EsEndpoint string
ElbEndpoint string
IamEndpoint string
Expand Down Expand Up @@ -389,6 +390,7 @@ func (c *Config) Client() (interface{}, error) {
awsEc2Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.Ec2Endpoint)})
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)})
awsElbSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})
awsEsSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.EsEndpoint)})
awsIamSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.IamEndpoint)})
Expand Down Expand Up @@ -473,7 +475,7 @@ func (c *Config) Client() (interface{}, error) {
client.dynamodbconn = dynamodb.New(awsDynamoSess)
client.ecrconn = ecr.New(awsEcrSess)
client.ecsconn = ecs.New(awsEcsSess)
client.efsconn = efs.New(sess)
client.efsconn = efs.New(awsEfsSess)
client.elasticacheconn = elasticache.New(sess)
client.elasticbeanstalkconn = elasticbeanstalk.New(sess)
client.elastictranscoderconn = elastictranscoder.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 @@ -688,6 +688,8 @@ func init() {

"ec2_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",
Expand Down Expand Up @@ -795,6 +797,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config.Ec2Endpoint = endpoints["ec2"].(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.IamEndpoint = endpoints["iam"].(string)
Expand Down Expand Up @@ -941,6 +944,13 @@ func endpointsSchema() *schema.Schema {
Description: descriptions["ecs_endpoint"],
},

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

"elb": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1031,6 +1041,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["efs"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["elb"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["kinesis"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["kms"].(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 @@ -299,6 +299,10 @@ Nested `endpoints` block supports the following:
URL constructed from the `region`. It's typically used to connect to
custom ELB endpoints.

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

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

0 comments on commit d53b1c2

Please sign in to comment.