|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +--- |
| 4 | + |
| 5 | +import Tabs from "@theme/Tabs"; |
| 6 | +import TabItem from "@theme/TabItem"; |
| 7 | +import Image from "@theme/IdealImage"; |
| 8 | + |
| 9 | +# Live Events Setup |
| 10 | + |
| 11 | +Port's AWS integration supports real-time event processing, allowing for accurate real-time representation of your AWS infrastructure inside Port. This guide explains how to set up live events for your AWS resources. |
| 12 | + |
| 13 | +:::info Current Limitations |
| 14 | +Live events are currently only available for: |
| 15 | +- **Single account installations** (not multi-account) |
| 16 | +- **Default Terraform installation** with support for 3 resource types by default: |
| 17 | + - EC2 Instances |
| 18 | + - S3 Buckets |
| 19 | + - CloudFormation Stacks |
| 20 | +::: |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +Before setting up live events, ensure you have: |
| 25 | + |
| 26 | +1. **AWS Integration Installed**: Complete the [AWS integration installation](./installation.md) first |
| 27 | +2. **API Gateway Setup**: The integration requires an API Gateway endpoint (automatically created with Terraform installation) |
| 28 | +3. **Port API Key**: Your Port API key for authentication |
| 29 | +4. **AWS Permissions**: Ability to create EventBridge rules in your AWS account |
| 30 | + |
| 31 | +:::tip Terraform vs Manual Installation |
| 32 | +- **Terraform users**: Use the provided Terraform module for automated setup |
| 33 | +- **Manual installation users**: Follow the AWS console setup steps |
| 34 | +::: |
| 35 | + |
| 36 | +## How Live Events Work |
| 37 | + |
| 38 | +<Image img={require("../../../static/img/build-your-software-catalog/sync-data-to-catalog/cloud-providers/aws/live-events-diagram.svg")} /> |
| 39 | + |
| 40 | +Live events work by: |
| 41 | + |
| 42 | +1. **AWS Services** generate events when resources change |
| 43 | +2. **CloudTrail** captures these events |
| 44 | +3. **EventBridge Rules** filter and route specific events |
| 45 | +4. **API Gateway** receives the events and forwards them to Port |
| 46 | +5. **Port Integration** processes the events and updates your software catalog |
| 47 | + |
| 48 | +## Setup Methods |
| 49 | + |
| 50 | +<Tabs> |
| 51 | +<TabItem value="terraform" label="Terraform (Recommended)" default> |
| 52 | + |
| 53 | +If you installed the AWS integration using Terraform, use the provided module to set up live events. |
| 54 | + |
| 55 | +### Supported Resource Types |
| 56 | + |
| 57 | +The default Terraform module supports live events for these resource types: |
| 58 | + |
| 59 | +- **EC2 Instances** (`AWS::EC2::Instance`) |
| 60 | +- **S3 Buckets** (`AWS::S3::Bucket`) |
| 61 | +- **CloudFormation Stacks** (`AWS::CloudFormation::Stack`) |
| 62 | + |
| 63 | +### Adding Custom Resource Types |
| 64 | + |
| 65 | +To add live events for additional resource types (like SSM Parameters), use the `aws_event_rule` module: |
| 66 | + |
| 67 | +```hcl |
| 68 | +module "aws_event_rule" { |
| 69 | + source = "port-labs/integration-factory/ocean//modules/aws_helpers/event" |
| 70 | + |
| 71 | + name = "port-aws-ocean-sync-ssm-parameters" |
| 72 | + description = "Capture Parameter Store change events" |
| 73 | + |
| 74 | + event_pattern = { |
| 75 | + source = ["aws.ssm"] |
| 76 | + detail-type = ["Parameter Store Change"] |
| 77 | + } |
| 78 | + |
| 79 | + input_paths = { |
| 80 | + resource_type = "AWS::SSM::Parameter" |
| 81 | + account_id = "$.account" |
| 82 | + aws_region = "$.region" |
| 83 | + event_name = "$.detail-type" |
| 84 | + identifier = "$.resources.0" |
| 85 | + } |
| 86 | +
|
| 87 | + api_key_param = "<live_events_api_key>" |
| 88 | + target_arn = "<api_gateway_arn>/production/POST/integration/webhook" |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +### Configuration Parameters |
| 93 | + |
| 94 | +| Parameter | Description | Example | |
| 95 | +|-----------|-------------|---------| |
| 96 | +| `name` | EventBridge rule name | `"port-aws-ocean-sync-ssm-parameters"` | |
| 97 | +| `description` | Rule description | `"Capture Parameter Store change events"` | |
| 98 | +| `event_pattern` | AWS event pattern to match | `{ source = ["aws.ssm"], detail-type = ["Parameter Store Change"] }` | |
| 99 | +| `input_paths` | JSON path mappings for event transformation | See example above | |
| 100 | +| `api_key_param` | Port API key parameter | `"<live_events_api_key>"` | |
| 101 | +| `target_arn` | API Gateway target ARN | `"<api_gateway_arn>/production/POST/integration/webhook"` | |
| 102 | + |
| 103 | +</TabItem> |
| 104 | +<TabItem value="manual" label="Manual AWS Console Setup"> |
| 105 | + |
| 106 | +If you installed the AWS integration manually, follow these steps to create EventBridge rules in the AWS console. |
| 107 | + |
| 108 | +### Step 1: Create a Rule |
| 109 | + |
| 110 | +1. Go to **EventBridge** → **Rules** → **Create rule** |
| 111 | +2. **Rule name**: Give it a descriptive name (e.g., `port-live-updates-ssm`) |
| 112 | +3. Click **Next** |
| 113 | + |
| 114 | +### Step 2: Define the Event Pattern |
| 115 | + |
| 116 | +1. **Event source**: Select "AWS events or services" |
| 117 | +2. **Event service**: Select the relevant AWS service (e.g., "Systems Manager") |
| 118 | +3. **Event type**: Select the type of event (e.g., "Parameter Store") |
| 119 | +4. **Event Type Specification**: Select "Specific detail type(s)" and choose the event type (e.g., "Parameter Store Change") |
| 120 | +5. Click **Next** |
| 121 | + |
| 122 | +### Step 3: Configure the Target |
| 123 | + |
| 124 | +1. **Target type**: Select "AWS Service" |
| 125 | +2. **Target**: Select "API Gateway" |
| 126 | +3. **Target location**: Select "Target in this account" |
| 127 | +4. **API**: Select the API Gateway created for your integration |
| 128 | +5. **Deployment stage**: Select "production" |
| 129 | +6. **Integration target**: Enter `/integration/webhook` (HTTP POST) |
| 130 | + |
| 131 | +### Step 4: Add Required Headers |
| 132 | + |
| 133 | +Add these required headers: |
| 134 | + |
| 135 | +| Header Name | Value | |
| 136 | +|-------------|-------| |
| 137 | +| `Content-Type` | `application/json` | |
| 138 | +| `x-port-aws-ocean-api-key` | `<your-api-key>` (replace with actual key) | |
| 139 | + |
| 140 | +### Step 5: Transform the Event Data |
| 141 | + |
| 142 | +Port expects a simplified payload. Use Input Transformer to map the raw AWS event: |
| 143 | + |
| 144 | +**Input Path (mapping):** |
| 145 | +```json |
| 146 | +{ |
| 147 | + "accountId": "$.account", |
| 148 | + "awsRegion": "$.region", |
| 149 | + "eventName": "$.detail-type", |
| 150 | + "identifier": "$.resources.0" |
| 151 | +} |
| 152 | +``` |
| 153 | + |
| 154 | +**Template (output):** |
| 155 | +```json |
| 156 | +{ |
| 157 | + "resource_type": "AWS::SSM::Parameter", |
| 158 | + "accountId": "<accountId>", |
| 159 | + "awsRegion": "<awsRegion>", |
| 160 | + "eventName": "<eventName>", |
| 161 | + "identifier": "<identifier>" |
| 162 | +} |
| 163 | +``` |
| 164 | + |
| 165 | +:::tip Resource Type Mapping |
| 166 | +Replace `"AWS::SSM::Parameter"` with the appropriate AWS resource type: |
| 167 | +- EC2 Instances: `"AWS::EC2::Instance"` |
| 168 | +- S3 Buckets: `"AWS::S3::Bucket"` |
| 169 | +- CloudFormation Stacks: `"AWS::CloudFormation::Stack"` |
| 170 | +::: |
| 171 | + |
| 172 | +### Step 6: Review & Create |
| 173 | + |
| 174 | +1. Click **Next** → **Next** → **Create rule** |
| 175 | +2. AWS will now forward matching events to Port automatically |
| 176 | + |
| 177 | +</TabItem> |
| 178 | +</Tabs> |
| 179 | + |
| 180 | +## Testing Your Setup |
| 181 | + |
| 182 | +### Verify Existing Rules |
| 183 | + |
| 184 | +If you have other live event rules (e.g., S3 Bucket sync), verify they're working: |
| 185 | + |
| 186 | +1. Go to **EventBridge** → **Rules** |
| 187 | +2. Check that your rules are **Enabled** |
| 188 | +3. Look for any recent invocations in the **Metrics** tab |
| 189 | + |
| 190 | +### Test Live Events |
| 191 | + |
| 192 | +1. **Trigger a test event**: |
| 193 | + - Modify/create a resource (e.g., create an SSM Parameter) |
| 194 | + - Update an existing resource |
| 195 | + - Delete a resource |
| 196 | + |
| 197 | +2. **Verify in Port**: |
| 198 | + - Check your software catalog for real-time updates |
| 199 | + - Look for the resource changes in Port's interface |
| 200 | + |
| 201 | +### Example Test for SSM Parameters |
| 202 | + |
| 203 | +1. Go to **Systems Manager** → **Parameter Store** |
| 204 | +2. Create a new parameter: |
| 205 | + - Name: `/test/my-parameter` |
| 206 | + - Type: `String` |
| 207 | + - Value: `test-value` |
| 208 | +3. Check Port for the new parameter entity |
| 209 | + |
| 210 | +## Troubleshooting |
| 211 | + |
| 212 | +### Common Issues |
| 213 | + |
| 214 | +**Events not appearing in Port:** |
| 215 | +- Verify the EventBridge rule is enabled |
| 216 | +- Check that the API Gateway endpoint is correct |
| 217 | +- Ensure the Port API key is valid |
| 218 | +- Verify the input transformer mapping is correct |
| 219 | + |
| 220 | +**Wrong resource type in Port:** |
| 221 | +- Check the `resource_type` field in your input transformer template |
| 222 | +- Ensure it matches the expected AWS resource type |
| 223 | + |
| 224 | +**Missing headers:** |
| 225 | +- Verify both `Content-Type` and `x-port-aws-ocean-api-key` headers are set |
| 226 | +- Check that the API key is the correct one for your Port environment |
| 227 | + |
| 228 | +### Debugging Steps |
| 229 | + |
| 230 | +1. **Check EventBridge Metrics**: |
| 231 | + - Go to EventBridge → Rules → Your Rule → Metrics |
| 232 | + - Look for successful invocations and any errors |
| 233 | + |
| 234 | +2. **Check API Gateway Logs**: |
| 235 | + - Go to API Gateway → Your API → Stages → production → Logs |
| 236 | + - Look for incoming requests and any errors |
| 237 | + |
| 238 | +3. **Verify Event Pattern**: |
| 239 | + - Test your event pattern with sample events |
| 240 | + - Use EventBridge's "Test pattern" feature |
| 241 | + |
| 242 | +## Supported AWS Services |
| 243 | + |
| 244 | +The following AWS services can be configured for live events: |
| 245 | + |
| 246 | +| Service | Event Source | Detail Type | Resource Type | |
| 247 | +|---------|--------------|-------------|---------------| |
| 248 | +| EC2 | `aws.ec2` | `EC2 Instance State-change Notification` | `AWS::EC2::Instance` | |
| 249 | +| S3 | `aws.s3` | `Object Created`, `Object Deleted` | `AWS::S3::Bucket` | |
| 250 | +| CloudFormation | `aws.cloudformation` | `CloudFormation Stack State Change` | `AWS::CloudFormation::Stack` | |
| 251 | +| Systems Manager | `aws.ssm` | `Parameter Store Change` | `AWS::SSM::Parameter` | |
| 252 | + |
| 253 | +:::info Adding More Services |
| 254 | +To add live events for additional AWS services, follow the same pattern: |
| 255 | +1. Identify the service's event source and detail type |
| 256 | +2. Create an EventBridge rule with the appropriate pattern |
| 257 | +3. Configure the input transformer with the correct resource type |
| 258 | +::: |
| 259 | + |
| 260 | +## Next Steps |
| 261 | + |
| 262 | +After setting up live events: |
| 263 | + |
| 264 | +1. **Monitor Performance**: Keep an eye on EventBridge metrics and API Gateway logs |
| 265 | +2. **Scale as Needed**: Add more resource types as your requirements grow |
| 266 | +3. **Optimize Patterns**: Fine-tune event patterns to reduce noise and improve performance |
| 267 | + |
| 268 | +For more advanced configuration options, see the [AWS integration examples](../examples/examples.md). |
| 269 | + |
0 commit comments