Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

AWS Integration Pack

The StackStorm AWS integration pack supplies action integration for numerous AWS services.

Prerequisites

AWS and Stackstorm, up and running.

Setup

Install AWS pack on StackStorm

  1. Install the AWS pack:

    # Install AWS
    st2 pack install aws
    # Check it
    st2 action list -p aws
    
  2. Copy the example configuration in aws.yaml.example to /opt/stackstorm/configs/aws.yaml and edit as required. It must contain:

  • region - Region where AWS commands will be executed
  • aws_access_key_id - Access key
  • aws_secret_access_key_id - Secret Access key

You can generate the access key and secret access key by following these directions:

http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html#Using_CreateAccessKey

If you would like to use the IAM role assigned to the instance stackstorm is running set the key and secret to None and set the region.

---
region: "us-east-1"aws_access_key_id: Noneaws_secret_access_key: Nonest2_user_data: ""

In previous versions there was a 'setup' object within the config, which has been deprecated. This will break the configuration where iam roles are being used:

  • service_notifications_sensor.host - Listen host for the HTTP interface.
  • service_notifications_sensor.port - Listen port for the HTTP interface.
  • service_notifications_sensor.path - Path where the events need to be sent.

Note : When modifying the configuration in /opt/stackstorm/configs/ please remember to tell StackStorm to load these new values by running st2ctl reload --register-configs

st2_user_data

Optionally, you can add the UserData with a set of provisioning instructions to be used when using the ec2_run_instances action.

Note that the ec2 boto3 SDK requires the parameter UserData, for the aws.ec2_run_instances action. This was previosly user_data.

Put your user_data file somewhere accessible by the StackStorm user, and use the st2_user_data config option to set it. This file/script will be used for all invocations of the ec2_run_instances action:

st2_user_data: "/full/path/to/file"

Alternatively, user data can be specified inline:

st2_user_data: | #!/bin/bash echo "I'm EC2 user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html"

Actions

Prior to installation of the aws pack, you can get the list of available actions here:

https://github.com/StackStorm-Exchange/stackstorm-aws/tree/master/actions

Once you have installed the aws pack, you can get a list of actions in the AWS pack using:

st2 action list -p aws

To get information on a specific action, please run:

root@2e1d15fd5d07:/# st2 action get aws.route53_list_hosted_zones
+-------------+--------------------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------------------+
| id | 594bfa4ed5d05c0b7e504803 |
| uid | action:aws:route53_list_hosted_zones |
| ref | aws.route53_list_hosted_zones |
| pack | aws |
| name | route53_list_hosted_zones |
| enabled | True |
| entry_point | run.py |
| runner_type | run-python |
| parameters | { |
| | "DelegationSetId": { |
| | "type": "string", |
| | "description": "If you"re using reusable delegation |
| | sets and you want to list all of the hosted zones that are |
| | associated with a reusable delegation set, specify the ID of |
| | that reusable delegation set. " |
| | }, |
| | "headers": { |
| | "type": "string" |
| | }, |
| | "MaxItems": { |
| | "type": "string", |
| | "description": "(Optional) The maximum number of |
| | hosted zones to be included in the response body for this |
| | request. If you have more than maxitems hosted zones, the |
| | value of the IsTruncated element in the response is true, |
| | and the value of the NextMarker element is the hosted zone |
| | ID of the first hosted zone in the next group of maxitems |
| | hosted zones." |
| | }, |
| | "Marker": { |
| | "type": "string", |
| | "description": "(Optional) If you have more hosted |
| | zones than the value of maxitems, ListHostedZones returns |
| | only the first maxitems hosted zones. To get the next group |
| | of maxitems hosted zones, submit another request to |
| | ListHostedZones. For the value of marker, specify the value |
| | of the NextMarker element that was returned in the previous |
| | response. Hosted zones are listed in the order in which they |
| | were created." |
| | }, |
| | "module_path": { |
| | "default": "boto3", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "action": { |
| | "default": "list_hosted_zones", |
| | "type": "string", |
| | "immutable": true |
| | }, |
| | "cls": { |
| | "default": "route53", |
| | "type": "string" |
| | } |
| | } |
| notify | |
| tags | |
+-------------+--------------------------------------------------------------+

Since this action does not take any required parameters and won't create any resources that will cost us anything, let's run it and see what it returns.

$ st2 run aws.route53_list_hosted_zones
.
id: 594cc1c2d5d05c1185bd51e5
status: succeeded
parameters: None
result:
exit_code: 0
result:
- HostedZones:
- CallerReference: 63FC852C-8B5F-12F9-8945-BC8FF413430A
Config:
PrivateZone: false
Id: /hostedzone/Z2MDOUVGZHYDZ7
Name: example.com.
ResourceRecordSetCount: 8
IsTruncated: false
MaxItems: '100'
ResponseMetadata:
HTTPHeaders:
content-length: '464'
content-type: text/xml
date: Fri, 23 Jun 2017 07:22:42 GMT
x-amzn-requestid: cf583b3d-57f4-11e7-a217-4b0c7596d765
HTTPStatusCode: 200
RequestId: cf583b3d-57f4-11e7-a217-4b0c7596d765
RetryAttempts: 0
stderr: ''
stdout: ''

To regenerate the actions used by this pack, run the following:

source /opt/stackstorm/virtualenvs/aws/bin/activate
cd /opt/stackstorm/packs/aws/etc/st2packgen
python st2packgen.py -d /opt/stackstorm/packs/aws/actions
st2ctl reload --register-actions

st2packgen.py will overwrite any existing actions at /opt/stackstorm/packs/aws/actions.

Sensors

ServiceNotificationsSensor

This sensor exposes a HTTP interface and listens for service event notifications which are delivered via AWS SNS service using HTTP(s) endpoint.

Currently it supports event notifications generated by the S3 service - http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

Keep in mind that this sensor doesn't implement any kind of authentication. This means that if the sensor is not behind a proxy which implements authentication and is accessible to the outside world, you need to configure path setting to include a random secret which is only known to the AWS SNS service.

aws.service_notification

This trigger is emitted for every service event notification.

Example trigger payload:

{
"source": "aws:s3",
"region": "us-west-2",
"name": "ObjectCreated:Put",
"timestamp": 123456789,
"response_elements": {
"x-amz-id-2": "blahid//4U+rk=",
"x-amz-request-id": "5FF5BB6EDE3631F8"
},
"request_parameters": {
"sourceIPAddress": "127.0.0.1"
},
"payload": {
"configurationId": "snsnotificationforput",
"object": {
"eTag": "5dfd7f29bce6d94dc5c73553f269659b",
"key": "myfile.tar.gz",
"size": 178428
},
"bucket": {
"ownerIdentity": {
"principalId": "BLAHBLAH"
},
"name": "testbucket33333",
"arn": "arn:aws:s3:::testbucket33333"
},
"s3SchemaVersion": "1.0"
}
}

source, region, name and timestamp attributes are included with all the events, but the format and values inside the payload attribute different across different services and event types.

For a list of supported S3 event types see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types

AWS SQS sensor

This is generic SQS Sensor using boto3 api to fetch messages from SQS queue. After receiving a message it's content is passed as payload to a trigger 'aws.sqs_new_message'

This sensor can be configured either by using aws.yaml or by creating following values in datastore:

  • aws.input_queues (list queues as comma separated string: first_queue,second_queue)
  • aws.aws_access_key_id
  • aws.aws_secret_access_key
  • aws.region
  • aws.max_number_of_messages (must be between 1 - 10)

For configuration in aws.yaml with config like this

aws_access_key_id:
aws_access_key_id:
region:
sqs_sensor:
input_queues:
- first_queue
- second_queue (queue list can be url or queue name)sqs_other:
max_number_of_messages: 1

If any value exist in datastore it will be taken instead of any value in aws.yaml

aws.sqs_new_message

This trigger is emitted when a single message is received from a queue.

{
"queue": "first_sqs_queue",
"body": "example message body"
}

Troubleshooting

If there are connection errors in st2sensorcontainer.log such as: 2020-02-06 22:04:05,202 140016844996688 INFO connectionpool [-] Starting new HTTP connection (1): 169.254.169.254. It's likely a result of turning on the sensor without copying the aws.yaml over to /opt/stackstorm/configs/aws.yaml

About

st2 content pack containing Amazon Web Services integrations.

Resources

Stars

15 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages