Skip to content

Commit fc34e18

Browse files
committed
add S3 IAM validation feature flag
1 parent f8faddb commit fc34e18

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

packages/destination-actions/src/destinations/liveramp-audiences/__tests__/liveramp.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import nock from 'nock'
22
import { createTestIntegration, PayloadValidationError, SegmentEvent } from '@segment/actions-core'
33
import Destination from '../index'
44
import fs from 'fs'
5-
import { LIVERAMP_MIN_RECORD_COUNT, LIVERAMP_ENABLE_COMPRESSION_FLAG_NAME } from '../properties'
5+
import {
6+
LIVERAMP_MIN_RECORD_COUNT,
7+
LIVERAMP_ENABLE_COMPRESSION_FLAG_NAME,
8+
LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME
9+
} from '../properties'
610

711
const testDestination = createTestIntegration(Destination)
812

@@ -359,6 +363,9 @@ describe('Liveramp Audiences', () => {
359363
settings: {
360364
__segment_internal_engage_force_full_sync: true,
361365
__segment_internal_engage_batch_sync: true
366+
},
367+
features: {
368+
[LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME]: true
362369
}
363370
})
364371
// Should not reach here
@@ -393,6 +400,9 @@ describe('Liveramp Audiences', () => {
393400
settings: {
394401
__segment_internal_engage_force_full_sync: true,
395402
__segment_internal_engage_batch_sync: true
403+
},
404+
features: {
405+
[LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME]: true
396406
}
397407
})
398408
// Should not reach here
@@ -428,6 +438,9 @@ describe('Liveramp Audiences', () => {
428438
settings: {
429439
__segment_internal_engage_force_full_sync: true,
430440
__segment_internal_engage_batch_sync: true
441+
},
442+
features: {
443+
[LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME]: true
431444
}
432445
})
433446
// Should not reach here
@@ -463,6 +476,9 @@ describe('Liveramp Audiences', () => {
463476
settings: {
464477
__segment_internal_engage_force_full_sync: true,
465478
__segment_internal_engage_batch_sync: true
479+
},
480+
features: {
481+
[LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME]: true
466482
}
467483
})
468484
// Should not reach here

packages/destination-actions/src/destinations/liveramp-audiences/audienceEnteredS3/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { sendEventToAWS } from '../awsClient'
55
import {
66
LIVERAMP_MIN_RECORD_COUNT,
77
LIVERAMP_LEGACY_FLOW_FLAG_NAME,
8-
LIVERAMP_ENABLE_COMPRESSION_FLAG_NAME
8+
LIVERAMP_ENABLE_COMPRESSION_FLAG_NAME,
9+
LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME
910
} from '../properties'
1011

1112
import type { Settings } from '../generated-types'
@@ -145,7 +146,10 @@ async function processData(input: ProcessDataInput<Payload>, subscriptionMetadat
145146

146147
// skip for legacy flow to avoid snapshot issues
147148
if (!(input.features && input.features[LIVERAMP_LEGACY_FLOW_FLAG_NAME] === true)) {
148-
await validateS3Permissions(input.payloads[0], input.request)
149+
// only validate S3 permissions when the validation flag is enabled
150+
if (input.features && input.features[LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME] === true) {
151+
await validateS3Permissions(input.payloads[0], input.request)
152+
}
149153
}
150154

151155
// validate s3 path

packages/destination-actions/src/destinations/liveramp-audiences/audienceEnteredS3/s3.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,7 @@ async function validateS3Permissions(
152152
payload: Payload,
153153
request: <Data = unknown>(url: string, options?: RequestOptions) => Promise<ModifiedResponse<Data>>
154154
) {
155-
if (
156-
!payload.s3_aws_access_key ||
157-
!payload.s3_aws_secret_key ||
158-
!payload.s3_aws_bucket_name ||
159-
!payload.s3_aws_region
160-
) {
155+
if (!payload.s3_aws_access_key || !payload.s3_aws_secret_key || !payload.s3_aws_bucket_name) {
161156
throw new PayloadValidationError('Missing required S3 credentials.')
162157
}
163158

packages/destination-actions/src/destinations/liveramp-audiences/properties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const ACTION_SLUG = 'actions-liveramp-audiences'
22

33
export const LIVERAMP_LEGACY_FLOW_FLAG_NAME = 'actions-liveramp-audiences-legacy-flow'
44
export const LIVERAMP_MIN_RECORD_COUNT = 25
5-
5+
export const LIVERAMP_S3_IAM_VALIDATION_FLAG_NAME = 'actions-liveramp-audiences-validate-s3-IAM'
66
export const LIVERAMP_SFTP_SERVER = 'files.liveramp.com'
77
export const LIVERAMP_SFTP_PORT = 22
88
export const LIVERAMP_ENABLE_COMPRESSION_FLAG_NAME = 'actions-liveramp-audiences-enable-compression'

0 commit comments

Comments
 (0)