You can easily send authenticated AWS Rest API calls with the Send HTTP request step using the AWS Signature Version 4 (AWS SigV4) authorization option. The credentials required for AWS SigV4 authentication (AWS access key ID and AWS secret access key) can be securely stored in Torq using the AWS REST API integration. Alternatively, you can use the AWS steps integration with AWS CLI to run sts assume-role
commands to obtain those credentials dynamically.
There are two ways to use AWS REST APIs with HTTP Steps and SigV4 authentication:
Via the AWS REST API integration with user access keys as SigV4 credentials
Via the AWS Steps integration to assume an STS role with a AWS CLI Step and then use the provided credentials in subsequent HTTP Steps
Use AWS SigV4 with HTTP steps and the AWS REST API integration
Step one: Create an AWS access key
Open AWS IAM: Sign in to the AWS Management Console and go to IAM.
Select the user: Go to Users and select the relevant user.
Create an access key: Click the Security credentials tab and then Create access key.
Select a use case for your access key and review the suggested alternatives.
Click Next.
(Optional) Add a descriptive tag.
Click Create access key.
Finalize: Copy the access key ID and secret access key to save them for later—you will need them when creating the AWS REST API steps integration in Torq.
Step two: Create an AWS REST API integration in Torq
Navigate to the integration: Go to Build > Integrations > Steps > AWS REST API and click Add Instance.
Configure the integration:
Step three: Authorize calls with AWS SigV4
Some AWS REST API output is in XML format. Use the Convert to JSON step to convert from XML to JSON.
The following is an example of a workflow that returns EC2 instance details.
Open the workflow: Navigate to Build > Workflows and select the relevant workflow.
Add the Send an HTTP request step: Drag and drop the Send an HTTP request step into the workflow.
Configure the step parameters: Open the HTTP step.
Paste the REST API endpoint URL.
Select the POST call method.
Select AWS SigV4 as the authorization.
For the AWS access key ID parameter, use the workflow context to select the access key ID from the AWS REST API integration instance you created earlier (e.g.
{{ $.integrations.aws_read_only_user.access_key_id }}
).For the AWS secret access parameter, use the workflow context to select the secret access key from the AWS REST API integration instance you created earlier (e.g.
{{ $.integrations.aws_read_only_user.secret_access_key }}
).For the AWS service parameter, select ec2 from the dropdown menu or from the workflow context.
For the AWS region parameter, select the relevant AWS region from the dropdown menu or from the workflow context.
Some regions need to be included in both the endpoint URL and the selection (e.g.
https://s3.amazonaws.com/
works forus-east-1
but fails formx-central-1
, unless the endpoint is updated tohttps://s3.mx-central-1.amazonaws.com/
).
Add the content type: Add the Content type parameter and select application/x-www-urlencoded; charset=utf-8.
Add the version: In the Body section, click + Add Field.
For Name, enter
Version
.For Value, enter the version date in the format YYYY-MM-DD.
Add the action: In the Body section, click + Add Field again.
For Name, enter
Action
.For Value, enter the CLI command action such as
DescribeInstances
.
Add the instance ID: In the Body section, click + Add Field again.
For Name, enter a name such as
InstanceId.1
.For Value, enter the instance ID such as
i-0123456789abcdef0
.
(Optional) Add the Convert to JSON step: Drag and drop a Convert to JSON step into the workflow to convert the XML output of the HTTP step to JSON.
Execute the steps: Click Execute to test the steps, and then check the Execution Logs to confirm everything is running as expected.
Use AWS SigV4 with HTTP steps and the AWS CLI integration
AWS CLI steps require an AWS steps integration.
The following is an example of a workflow that returns EC2 instance details.
Set up an AWS steps integration instance: See the guide on creating an AWS steps integration instance.
Open the workflow: Navigate to Build > Workflows and select the relevant workflow.
Assume an STS role: See the guide on configuring a AWS CLI step to run an
aws sts assume-role
command.Add the Send an HTTP request step: Drag and drop the Send an HTTP request step into the workflow.
Configure the step parameters: Open the HTTP step.
Paste the call request URL.
Select the POST call method.
Select AWS SigV4 as the authorization.
For the AWS access key ID parameter, use the workflow context to select
AccessKeyId
from the output of the previous AWS CLI step in which thests assume-role
command was executed.For the AWS secret access parameter, use the workflow context to select
SecretAccessKey
from the previous assume role step.For the AWS service parameter, select ec2 from the dropdown menu or from the workflow context.
For the AWS region parameter, select the relevant AWS region from the dropdown menu or from the workflow context.
Some regions need to be included in both the endpoint URL and the selection (e.g.
https://s3.amazonaws.com/
works forus-east-1
but fails formx-central-1
, unless the endpoint is updated tohttps://s3.mx-central-1.amazonaws.com/
).
Add a header to the step: In the Headers section, click + Add.
For Key, enter
X-Amz-Security-Token
.For Value, use the workflow context to select
SessionToken
from the assume role step.
Add the content-type: Add the content-type parameter and select application/x-www-urlencoded; charset=utf-8.
Add the version: In the Body section, click + Add Field.
For Name, enter
Version
.For Value, enter the version date in the format YYYY-MM-DD.
Add the action: In the Body section, click + Add Field again.
For Name, enter
Action
.For Value, enter
DescribeInstances
.
Add the instance ID: In the Body section, click + Add Field again.
For Name, enter a name such as
InstanceId.1
.For Value, enter the instance ID such as
i-0123456789abcdef0
.
(Optional) Add the Convert to JSON step: Drag and drop a Convert to JSON step into the workflow to convert the XML output of the HTTP step to JSON.
Execute the steps: Click Execute to test the steps, and then check the Execution Logs to confirm everything is running as expected.