-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added AWS enpoint handling #3416
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ func getRootConfig(s logical.Storage) (*aws.Config, error) { | |
credsConfig.AccessKey = config.AccessKey | ||
credsConfig.SecretKey = config.SecretKey | ||
credsConfig.Region = config.Region | ||
credsConfig.Endpoint = config.Endpoint | ||
} | ||
|
||
if credsConfig.Region == "" { | ||
|
@@ -51,6 +52,7 @@ func getRootConfig(s logical.Storage) (*aws.Config, error) { | |
return &aws.Config{ | ||
Credentials: creds, | ||
Region: aws.String(credsConfig.Region), | ||
Endpoint: aws.String(credsConfig.Endpoint), | ||
HTTPClient: cleanhttp.DefaultClient(), | ||
}, nil | ||
} | ||
|
@@ -60,7 +62,13 @@ func clientIAM(s logical.Storage) (*iam.IAM, error) { | |
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client := iam.New(session.New(awsConfig)) | ||
|
||
if *awsConfig.Endpoint != "none" { | ||
client = iam.New(session.New(awsConfig.WithEndpoint(*awsConfig.Endpoint))) | ||
} | ||
|
||
if client == nil { | ||
return nil, fmt.Errorf("could not obtain iam client") | ||
} | ||
|
@@ -73,6 +81,9 @@ func clientSTS(s logical.Storage) (*sts.STS, error) { | |
return nil, err | ||
} | ||
client := sts.New(session.New(awsConfig)) | ||
if *awsConfig.Endpoint != "none" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same -- use |
||
client = sts.New(session.New(awsConfig.WithEndpoint(*awsConfig.Endpoint))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're configuring STS and IAM clients with the same endpoints, and I doubt that will work. They likely need different endpoints. |
||
} | ||
if client == nil { | ||
return nil, fmt.Errorf("could not obtain sts client") | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ func pathConfigRoot() *framework.Path { | |
Type: framework.TypeString, | ||
Description: "Region for API calls.", | ||
}, | ||
"endpoint": &framework.FieldSchema{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want separate |
||
Type: framework.TypeString, | ||
Description: "Endpoint to custom IAM server URL", | ||
}, | ||
}, | ||
|
||
Callbacks: map[logical.Operation]framework.OperationFunc{ | ||
|
@@ -37,10 +41,16 @@ func pathConfigRoot() *framework.Path { | |
func pathConfigRootWrite( | ||
req *logical.Request, data *framework.FieldData) (*logical.Response, error) { | ||
region := data.Get("region").(string) | ||
endpoint := data.Get("endpoint").(string) | ||
|
||
if endpoint == "" { | ||
endpoint = "none" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't use |
||
} | ||
|
||
entry, err := logical.StorageEntryJSON("config/root", rootConfig{ | ||
AccessKey: data.Get("access_key").(string), | ||
SecretKey: data.Get("secret_key").(string), | ||
Endpoint: endpoint, | ||
Region: region, | ||
}) | ||
if err != nil { | ||
|
@@ -57,6 +67,7 @@ func pathConfigRootWrite( | |
type rootConfig struct { | ||
AccessKey string `json:"access_key"` | ||
SecretKey string `json:"secret_key"` | ||
Endpoint string `json:"endpoint"` | ||
Region string `json:"region"` | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See note about not using
"none"
as a placeholder, use""