Calling AWS Services

To programmatically connect to the AWS Services, need to use endpoints. The AWS SDK and the CLI use the default endpoint of the region to access the service. The regional endpoint is protocol://service-code.region-code.amazonaws.com standard. But services such as IAM not support the region.

Some example of calling1 to AWS services via API calls. All CLI calls are signed by Signature version 42. To list all the active regions: (if you want to sort add the | sort to the end.

aws ssm get-parameters-by-path --path /aws/service/global-infrastructure/regions --query Parameters[].Name

In the above command regions is the important word.

This command will return the following:

---------------------------------------------------------------
|                     GetParametersByPath                     |
+-------------------------------------------------------------+
|  /aws/service/global-infrastructure/regions/ap-northeast-1  |
|  /aws/service/global-infrastructure/regions/eu-central-1    |
|  /aws/service/global-infrastructure/regions/eu-north-1      |
|  /aws/service/global-infrastructure/regions/eu-west-3       |
|  /aws/service/global-infrastructure/regions/me-south-1      |
...
...
...

To list all the available services:

aws ssm get-parameters-by-path --path /aws/service/global-infrastructure/services --query Parameters[].Name

In the above command services is the most important word.

------------------------------------------------------------------------------
|                             GetParametersByPath                            |
+----------------------------------------------------------------------------+
|  /aws/service/global-infrastructure/services/codestar-connections          |
|  /aws/service/global-infrastructure/services/datasync                      |
|  /aws/service/global-infrastructure/services/elastictranscoder             |
|  /aws/service/global-infrastructure/services/frauddetector                 |
|  /aws/service/global-infrastructure/services/logs                          |
|  /aws/service/global-infrastructure/services/route53                       |
|  /aws/service/global-infrastructure/services/servicediscovery              |
...
...
...

you get something similar to above as a return.

For example you can find the service S3 available regions as follows:

aws ssm get-parameters-by-path --path /aws/service/global-infrastructure/services/s3/regions --query Parameters[].Value

The result is:

---------------------
|GetParametersByPath|
+-------------------+
|  ap-east-1        |
|  ap-northeast-1   |
|  cn-northwest-1   |
|  eu-central-1     |
|  eu-west-2        |
|  eu-west-3        |
|  sa-east-1        |
|  us-gov-east-1    |
...
...
...

To view the regional endpoints for S3:

aws ssm get-parameter --name /aws/service/global-infrastructure/regions/us-west-1/services/s3/endpoint --query Parameter.Value

Reference:

Comments

Popular posts from this blog

How To: GitHub projects in Spring Tool Suite

Spring 3 Part 7: Spring with Databases

Parse the namespace based XML using Python