Custom endpoint in AWS powershell
I do not believe that this is so. This list of common parameters (which can be used with all AWS PowerShell cmdlets) does not include the service URL, instead it prefers a simple string Region
to set the service URL based on a set of known regions.
This AWS.NET Development forum suggests you to set a service URL in the .NET SDK config object if you are interested in a possible alternative in PowerShell. Here's a usage example from this thread:
$config=New-Object Amazon.EC2.AmazonEC2Config
$config.ServiceURL = "https://ec2.us-west-1.amazonaws.com"
$client=[Amazon.AWSClientFactory]::CreateAmazonEC2Client($accessKeyID,$secretKeyID,$config)
It looks like you can use it with most of the config objects when setting up the client. Here are some examples that have a ServiceURL property. I would guess this applies to most of all AWS config objects:
Older versions of the documentation (for v1) have noted that this property will be ignored if set RegionEndpoint
. I'm not sure if this is still happening with v2.
source to share
- UPDATE -
Newer versions of AWS Tools for Windows PowerShell (I am running 3.1.66.0 according to Get-AWSPowerShellVersion), has an optional -EndpointUrl parameter for the corresponding commands.
Example:
Get-EC2Instance -EndpointUrl https://somehostnamehere
Also, a bug has been fixed .
Good material!
- ORIGINAL ANSWER -
TL; TR
- Download the default endpoint config file: https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/endpoints.json
-
Customize it. Example:
{ "version": 2, "endpoints": { "*/*": { "endpoint": "your_endpoint_here" } } }
-
After importing the AWSPowerShell module, tell the SDK to use the customized endpoint configuration. Example:
[Amazon.AWSConfigs]::EndpointDefinition = "path to your customized Amazon.endpoints.json here"
Note: There is a bug in the underlying SDK that causes the endpoints that have the path component to be signed correctly. The bug affects this solution and @HyperAnthony's solution is suggested.
Additional Information
Reading through the .NET SDK docs I came across a section that showed that the global can set the region rules given by the file: http://docs.aws.amazon.com/AWSSdkDocsNET/latest/V2/DeveloperGuide/net-dg-config- other.html # config-setting-awsendpointdefinition
Unfortunately, I couldn't find anywhere that documented the format of such a file.
Then I ran the AWSSDK.Core.dll code and found where the SDK is loading the file (see LoadEndpointDefinitions () at https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/RegionEndpoint .cs ).
Reading the code, if the file is not explicitly listed in AWSConfigs.EndpointDefinition, it ultimately downloads the file from the embedded resource (i.e. https://github.com/aws/aws-sdk-net/blob/master/sdk/src /Core/endpoints.json )
source to share