Programmatic access (machine-to-machine)
In addition to the web UI, you can call the solution API programmatically — for example, from a CI/CD pipeline or a scheduled job. Each programmatic caller authenticates as a machine-to-machine (M2M) client. The client is a dedicated IAM role deployed as its own AWS CloudFormation stack. Assume the role to obtain temporary credentials for signing API requests with AWS Signature Version 4 (SigV4). Each client role is isolated, can be revoked independently, and appears as a distinct principal in AWS CloudTrail.
Note
If your automation host makes programmatic calls, keep its clock synchronized (for example, using Network Time Protocol (NTP)). SigV4 rejects requests whose timestamp is more than five minutes out of sync with AWS.
Deploy an M2M client stack
Deploy one AWS CloudFormation stack for each client into the Hub account (the account where the Compute and Data stacks are deployed). Name the stack <stackPrefix>-M2mClient-<Role>-<clientName> and provide the following parameters:
| Parameter | Description |
|---|---|
|
|
The solution namespace of your deployment (for example, |
|
|
A short identifier for the automation (for example, |
|
|
The role tier the client acts as: |
|
|
The principal allowed to assume the client role — either a full IAM ARN (pins to one principal) or a 12-digit account ID (trusts any principal in that account that has |
|
|
The solution API Gateway REST API ID. Read it from the SSM parameter |
Deploy the stack from the solution’s published CloudFormation template using the AWS CloudFormation console or the AWS CLI. The template is available at:
https://solutions-reference.s3.amazonaws.com/innovation-sandbox-on-aws/latest/InnovationSandbox-M2mClient.template
After deployment, record these stack outputs; you need them to obtain credentials:
| Output key | Description |
|---|---|
|
|
The ARN of the IAM role the client assumes. |
|
|
A per-stack ExternalId that must be passed on the |
Construct a SigV4 client
From the trusted principal, use the stack outputs to obtain temporary credentials and sign requests:
-
Call
sts:AssumeRolewithM2MRoleArnandM2MExternalId. The calling principal’s own credentials must havests:AssumeRolepermission on the client role. The call returns a temporary access key, secret key, and session token. -
Sign each API request with SigV4 using those temporary credentials. Target the
execute-apiservice in the solution’s home Region. Any AWS SDK,curl --aws-sigv4, or the AWS CLI can produce the signature. Include the temporary session token in each request.
Temporary credentials expire after one hour by default. Long-running automation must re-assume the role before expiration.
Note
The assumed role is scoped to execute-api:Invoke only. Resolve the API Gateway invoke URL from the Compute stack outputs using your own credentials — the M2M role cannot describe stacks.
The scripts/m2m toolingassume-m2m-role.sh (assumes the role and exports credentials) and call-api.sh (signs and sends a request) — that you can use directly or adapt for your own automation.
Remove an M2M client
To permanently remove a client’s access, delete its CloudFormation stack using the AWS CloudFormation console or aws cloudformation delete-stack. This also deletes the IAM role. To immediately block access while leaving the stack intact — for example, in response to a suspected credential leak — use the revoke-m2m-role.sh script in the scripts/m2m tooling. This script denies or restores a client’s access and invalidates in-flight sessions without destroying the stack. For uninstall instructions, see Delete machine-to-machine client stacks.