Skip to content

Commit 637f88e

Browse files
authored
Merge pull request #2742 from segmentio/develop
Release 22.15.1
2 parents d8fc21b + 3f6f9bd commit 637f88e

File tree

4 files changed

+219
-11
lines changed

4 files changed

+219
-11
lines changed

Diff for: Gemfile.lock

100755100644
+3-3
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ GEM
104104
mercenary (0.4.0)
105105
mini_portile2 (2.8.0)
106106
multipart-post (2.1.1)
107-
nokogiri (1.13.3)
107+
nokogiri (1.13.4)
108108
mini_portile2 (~> 2.8.0)
109109
racc (~> 1.4)
110-
nokogiri (1.13.3-x86_64-darwin)
110+
nokogiri (1.13.4-x86_64-darwin)
111111
racc (~> 1.4)
112-
nokogiri (1.13.3-x86_64-linux)
112+
nokogiri (1.13.4-x86_64-linux)
113113
racc (~> 1.4)
114114
pathutil (0.16.2)
115115
forwardable-extended (~> 2.6)

Diff for: src/connections/destinations/catalog/talonone/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ id: 5de7c705e7d93d5e24742a04
66
---
77

88
> warning ""
9-
> Segment and Talon.One recommend you use the [Talon.One (Action) Destination](/docs/connections/destinations/catalog/slack/) instead.
9+
> Segment and Talon.One recommend you use the [Talon.One (Action) Destination](/docs/connections/destinations/catalog/talonone/) instead.
1010
1111
Create flexible and targeted promotional & loyalty campaigns with [Talon.One](https://Talon.One/?utm_source=segmentio&utm_medium=docs&utm_campaign=partners).
1212
Campaigns can be created and managed by non-technical users such as marketeers. There is no need to get your development team involved. Features include coupons, discounts, loyalty programs, referral tracking, geo-fencing, and bundling.

Diff for: src/connections/storage/catalog/aws-s3/index.md

+214-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ redirect_from:
55
hide-personas-partial: true
66
---
77

8-
98
## Differences between the Amazon S3 destination and the AWS S3 destination
109

1110
The AWS S3 destination provides a more secure method of connecting to your S3 buckets. It uses AWS's own IAM Roles to define access to the specified buckets. For more information about IAM Roles, see Amazon's [IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html){:target="_blank"} documentation.
@@ -27,11 +26,11 @@ The Segment Tracking API processes data from your sources, and collects the Even
2726

2827
![](images/s3processdiagram.png)
2928

30-
31-
3229
## Create a new destination
3330

34-
Complete either [Create an IAM role in the AWS console](#create-an-iam-role-in-the-aws-console) or [Create an IAM role using the AWS CLI](#create-an-iam-role-using-the-aws-cli) to configure the AWS S3 Destination with IAM Role Support.
31+
Complete either [Create an IAM role in the AWS console](#create-an-iam-role-in-the-aws-console), [Create an IAM role using the AWS CLI](#create-an-iam-role-using-the-aws-cli), or [Create IAM roles using Terraform](#create-iam-roles-using-terraform) to set up the AWS S3 Destination with IAM Role Support.
32+
33+
All three setup methods provide a base level of permissions to Segment. If you want stricter permissions or other custom configurations, you can customize these setup instructions manually.
3534

3635
### Create an IAM role in the AWS console
3736

@@ -193,6 +192,106 @@ To create an S3 IAM role, you must first install and configure the AWS CLI on yo
193192
> info ""
194193
> To verify that the IAM role is created, navigate to the AWS console and open the IAM Management Console. On the Permissions tab, verify that there is a `segment-s3-putobject` Permissions policy.
195194

195+
### Create IAM roles using Terraform
196+
197+
You can run the provided Terraform module from your command line to create the IAM roles required for this destination. This script requires access to Terraform versions v0.12+.
198+
199+
> warning "Support for the AWS S3 Terraform module"
200+
> If you’re familiar with Terraform, you can modify the module to meet your organization’s needs: however, Segment guarantees support only for the template as provided.
201+
202+
To set up the required IAM roles for this destination, run the following Terraform module from your command line:
203+
204+
```hcl
205+
# Creates the IAM role used by Segment.
206+
# https://www.terraform.io/docs/providers/aws/r/iam_role.html
207+
resource "aws_iam_role" "segment_aws_s3_iam_role" {
208+
name = "SegmentAWSS3Role"
209+
description = "IAM Role used by Segment"
210+
assume_role_policy = data.aws_iam_policy_document.segment_aws_s3_assume_role_policy_document.json
211+
}
212+
213+
# Trust relationship policy attached to the IAM role.
214+
# https://www.terraform.io/docs/providers/aws/d/iam_policy_document.html
215+
data "aws_iam_policy_document" "segment_aws_s3_assume_role_policy_document" {
216+
version = "2012-10-17"
217+
# Allows Segment to assume a role.
218+
statement {
219+
actions = [
220+
"sts:AssumeRole"
221+
]
222+
principals {
223+
type = "AWS"
224+
identifiers = ["arn:aws:iam::595280932656:role/segment-s3-integration-production-access", ]
225+
}
226+
effect = "Allow"
227+
condition {
228+
test = "StringEquals"
229+
variable = "sts:ExternalId"
230+
values = ["<YOUR_WORKSPACE_ID>", ]
231+
}
232+
}
233+
}
234+
235+
# https://www.terraform.io/docs/providers/aws/d/caller_identity.html
236+
data "aws_caller_identity" "current" {}
237+
# https://www.terraform.io/docs/providers/aws/d/region.html
238+
data "aws_region" "current" {}
239+
resource "aws_iam_policy" "segment_aws_s3_policy" {
240+
name = "SegmentAWSS3Policy"
241+
description = "Gives access to resources in your S3 bucket"
242+
policy = data.aws_iam_policy_document.segment_aws_s3_policy_document.json
243+
}
244+
245+
data "aws_iam_policy_document" "segment_aws_s3_policy_document" {
246+
version = "2012-10-17"
247+
# Allows Segment to write to your S3 bucket.
248+
statement {
249+
sid = "PutObjectsInBucket"
250+
actions = [
251+
"s3:PutObject",
252+
"s3:PutObjectAcl",
253+
]
254+
resources = [
255+
"arn:aws:s3:::<YOUR_BUCKET_NAME>/segment-logs/*",
256+
]
257+
effect = "Allow"
258+
}
259+
}
260+
261+
resource "aws_iam_role_policy_attachment" "segment_aws_s3_role_policy_attachment" {
262+
role = aws_iam_role.segment_aws_s3_iam_role.name
263+
policy_arn = aws_iam_policy.segment_aws_s3_policy.arn
264+
}
265+
266+
# Include the following sections if you’re using KMS encryption on your S3 bucket
267+
resource "aws_iam_policy" "segment_aws_s3_kms_policy" {
268+
name = "SegmentAWSS3KMSPolicy"
269+
path = "/"
270+
description = "Gives access to your KMS key"
271+
policy = data.aws_iam_policy_document.segment_aws_s3_kms_policy_document.json
272+
}
273+
274+
data "aws_iam_policy_document" "segment_aws_s3_kms_policy_document" {
275+
version = "2012-10-17"
276+
statement {
277+
sid = "AllowKMS"
278+
actions = [
279+
"kms:GenerateDataKey",
280+
"kms:Decrypt",
281+
]
282+
# ARN of your KMS key.
283+
resources = [
284+
"<YOUR_KEY_ARN>",
285+
]
286+
effect = "Allow"
287+
}
288+
}
289+
290+
resource "aws_iam_role_policy_attachment" "segment_aws_s3_role_kms_policy_attachment" {
291+
role = aws_iam_role.segment_aws_s3_iam_role.name
292+
policy_arn = aws_iam_policy.segment_aws_s3_kms_policy.arn
293+
}
294+
```
196295

197296
### Add the AWS S3 with IAM Role Support Destination
198297

@@ -212,8 +311,11 @@ To finish configuration, enable the AWS S3 Destination with IAM Role Support des
212311
> info ""
213312
> Did you know you can create destinations with the Config API? For more information, see [Create Destination](https://reference.segmentapis.com/#51d965d3-4a67-4542-ae2c-eb1fdddc3df6){:target="_blank"}.
214313
314+
## Migrate existing destinations
315+
316+
You can migrate your existing Amazon S3 destinations to the new AWS S3 destination either [manually](#manually-migrate-an-existing-destination) in the Segment app, or by using Segment's [Public API](#migrate-an-existing-destination-using-the-public-api).
215317

216-
## Migrate an existing destination
318+
### Manually migrate an existing destination
217319

218320
> warning "Avoid overwriting data"
219321
> Sending data to the same S3 location from both the existing Amazon S3 destination, and the AWS S3 with IAM Role Support destination will overwrite data in that location. To avoid this, follow the steps below.
@@ -228,7 +330,7 @@ To migrate an existing Amazon S3 destination to the AWS S3 with IAM Role Support
228330
6. Remove the test folder created in step 2 from the bucket.
229331

230332
> error " "
231-
> You need to migrate to the new S3 destination before you disable your legacy destination to ensure Segment continues to deliver data to your S3 bucket.
333+
> You must migrate to the new S3 destination before you disable your legacy destination to ensure Segment continues to deliver data to your S3 bucket.
232334
233335
### Migration steps for scenarios with multiple sources per environment
234336

@@ -245,6 +347,112 @@ For example:
245347

246348
For each source in the scenario, complete the steps described in [Migrate an existing destination](#migrate-an-existing-destination), and ensure that you have separate IAM Roles and Permissions set for staging and production use.
247349

350+
### Migrate an existing destination using the Public API
351+
This procedure uses Segment's Public API to migrate an existing Amazon S3 destination to the new AWS S3 destination. For more information about the Public API, see the [Public API documentation](https://api.segmentapis.com/docs/guides/#introduction){:target="_blank"}.
352+
353+
> warning "Avoid overwriting data"
354+
> Sending data to the same S3 location from both the existing Amazon S3 destination and the AWS S3 destinations will overwrite data in your instance of S3. To avoid this, disable your Amazon S3 destination after you create your AWS S3 destination.
355+
356+
To migrate to the AWS S3 destination using the Public API:
357+
358+
#### Step 1 - Verify your configuration
359+
360+
1. Open the Segment app, select the Connections tab and then select Catalog.
361+
2. From the Catalog, select the Storage Destinations tab and select the **AWS S3** destination.
362+
3. On the AWS S3 destination page, click the **Configure AWS S3** button.
363+
4. Configure your AWS S3 destination. When asked for the bucket name, enter `<YOUR_BUCKET_NAME>/segment-logs/test`.
364+
5. Enable the destination, and verify data is received at `<YOUR_BUCKET_NAME>/segment-logs/test/segment-logs`. <br/>**Note:** If the folder receives data, continue to the next step. If you don't see log entries, check the trust relationship document and IAM policy attached to your IAM role.
365+
366+
367+
#### Step 2 - Migrate an existing destination using the Public API
368+
369+
1. Identify the source IDs for your old Amazon S3 destination(s). You can use the Public API to return information about a list of your Amazon S3 destinations or an individual destination. <br/>
370+
To return a list of all of your Amazon S3 destinations, use the [`list destinations`](https://api.segmentapis.com/docs/connections/destinations/#list-destinations) call and filter the results using metadata id `54f418c3db31d978f14aa925` or slug `amazon-s3`: <br/>
371+
```shell
372+
curl -vvv --location --request GET https://api.segmentapis.com/destinations?pagination.count=1 \
373+
--header 'Content-Type: application/json' \
374+
--header 'Authorization: Bearer ...' \
375+
--data-raw '
376+
```
377+
To return the information for an individual Amazon S3 destination, use the [`get destination`](https://api.segmentapis.com/docs/connections/destinations/#get-destination) call, using the destination ID for your individual Amazon S3 destination (**Note:** The destination ID for your Amazon S3 source is visible in the Segment app, on the destination's settings page.) <br/>
378+
```shell
379+
curl -vvv --location --request GET https://api.segmentapis.com/destinations/$DESTINATION_ID \
380+
--header 'Content-Type: application/json' \
381+
--header 'Authorization: Bearer ...' \
382+
--data-raw '
383+
```
384+
2. Create your new AWS S3 destination using the [`create destination`](https://api.segmentapis.com/docs/connections/destinations/#create-destination) Public API call. The `sourceId`, `metadataId`, and `settings` parameters are required. An example of the parameters is below: <br/>
385+
```json
386+
{
387+
"sourceId": "$SOURCE_ID",
388+
"metadataId": "60be92c8dabdd561bf6c9130",
389+
"name": "AWS S3",
390+
"settings": {
391+
"region": "$BUCKET_REGION",
392+
"s3Bucket": "$YOUR_BUCKET_NAME",
393+
"iamRoleArn": "$IAM_ROLE_ARN"
394+
}
395+
```
396+
<br/>**Optional:** You can create a destination that's not enabled automatically upon creation by setting `enabled` to `false` when creating the new AWS S3 destination:
397+
<br/>
398+
```shell
399+
curl -vvv --location --request PATCH https://api.segmentapis.com/destinations/$DESTINATION_ID \
400+
--header 'Content-Type: application/json' \
401+
--header 'Authorization: Bearer ...' \
402+
--data-raw '
403+
{
404+
"destinationId": "$DESTINATION_ID",
405+
"enabled": false
406+
}
407+
' | jq
408+
```
409+
<br/>
410+
411+
3. Disable the Amazon S3 destinations using the following command, replacing `$DESTINATION_ID` with the ID of your Amazon S3 destination you found in a previous step:
412+
413+
```shell
414+
curl -vvv --location --request PATCH https://api.segmentapis.com/destinations/$DESTINATION_ID \
415+
--header 'Content-Type: application/json' \
416+
--header 'Authorization: Bearer ...' \
417+
--data-raw '
418+
{
419+
"destinationId": "$DESTINATION_ID",
420+
"enabled": false
421+
}
422+
' | jq
423+
```
424+
425+
> error " "
426+
> You must migrate to the new S3 destination before you disable your legacy destination to ensure Segment continues to deliver data to your S3 bucket.
427+
428+
## Test your migrated source
429+
You can validate that you configured your migrated source correctly on the AWS S3 destination page in the Segment app.
430+
431+
> note "Source editing permissions required"
432+
> In-app source validation is restricted to users with source editing permissions (for example, users with Workspace Owner, Source Admin, or Workspace Admin roles). For more information about roles in the Segment app, see the [Roles documentation](/docs/segment-app/iam/roles/).
433+
434+
To verify that you migrated your source correctly:
435+
1. Open the Segment app and select the AWS S3 destination.
436+
2. On the Settings page, verify that your Region, Bucket Name, and IAM Role ARN are all correct.
437+
3. Click **Validate.**
438+
4. A code indicating if the validation was successful or failed appears. To troubleshoot failed validation codes, see the [Troubleshooting](#troubleshooting) section.
439+
440+
> info "dummy-object.txt"
441+
> In order to test your bucket, Segment uploads a text file, `dummy-object.txt`, to the segment-logs folder in your S3 bucket. After you've completed the validation process, feel free to delete this file.
442+
443+
### Troubleshooting
444+
445+
The following table outlines some of the error codes the validation tool may display and possible reasons for the error. For assistance with correcting any of these error codes, contact [Segment support](mailto:[email protected]).
446+
447+
| Error message | Likely cause of the error |
448+
| ------------- | ------------------------- |
449+
| Unknown Error. Please try again. If the problem persists, please contact [Segment support](mailto:[email protected]). | Fail to assume intermediate role |
450+
| Access Denied. Please configure External ID in the AWS IAM Console. [Learn more](#create-an-iam-role-in-the-aws-console). | Successfully assumed customer's role, role doesn't have external ID |
451+
| Unknown Error. Please follow [instructions](#create-an-iam-role-in-the-aws-console) to set up the AWS S3 destination. If the problem persists, please contact [Segment support](mailto:[email protected]). | Fail to assume customer’s role without external ID and returned an error code that is not error 403 |
452+
| Access Denied. Please configure External ID in the AWS IAM Console. [Learn more](#create-an-iam-role-in-the-aws-console). | Fail to assume customer’s role without external ID and returned error 403 |
453+
| Access Denied. Please add PutObject permissions to the IAM role in the AWS IAM Console. [Learn more](#create-an-iam-role-in-the-aws-console). | Fail to upload the dummy object to customer's S3 bucket and an error code that is not error 403. |
454+
| Unknown Error. Please follow [instructions](#create-an-iam-role-in-the-aws-console) to set up the AWS S3 destination. If the problem persists, please contact [Segment support](mailto:[email protected]). | Fail to upload the dummy object to customer's S3 bucket and an error code that is not error 403. |
455+
248456

249457
## Data format
250458

Diff for: src/connections/storage/catalog/data-lakes/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Before you set up Segment Data Lakes, you need the following resources:
2020

2121
## Step 1 - Set Up AWS Resources
2222

23-
You can use the [open source Terraform module](https://github.com/segmentio/terraform-aws-data-lake) to automate much of the set up work to get Data Lakes up and running. If you’re familiar with Terraform, you can modify the module to meet your organization’s needs, however Segment guarantees support only for the template as provided. The Data Lakes set up uses Terraform v0.11+. To support more versions of Terraform, the AWS provider must use v2, which is included in our example main.tf.
23+
You can use the [open source Terraform module](https://github.com/segmentio/terraform-aws-data-lake) to automate much of the set up work to get Data Lakes up and running. If you’re familiar with Terraform, you can modify the module to meet your organization’s needs, however Segment guarantees support only for the template as provided. The Data Lakes set up uses Terraform v0.12+. To support more versions of Terraform, the AWS provider must use v4, which is included in our example main.tf.
2424

2525
You can also use Segment's [manual set up instructions](/docs/connections/storage/data-lakes/data-lakes-manual-setup) to configure these AWS resources if you prefer.
2626

0 commit comments

Comments
 (0)