-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated telemetry with tags (#37)
* updated telemetry with tags * pr suggestions
- Loading branch information
1 parent
d6ddff8
commit 5017ae0
Showing
14 changed files
with
105 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,27 +91,6 @@ describe('ControlPlane Targets', () => { | |
}); | ||
}); | ||
|
||
describe('ControlPlane description', () => { | ||
it('should have a fixed template description, when the containing stack does not have description', () => { | ||
const stackWithoutDescription = new TestStack(app, 'stackWithoutDescription', { | ||
systemAdminEmail: '[email protected]', | ||
}); | ||
const actual = stackWithoutDescription.templateOptions.description; | ||
const expected = 'SaaS Builder Toolkit - CoreApplicationPlane (uksb-1tupboc57)'; | ||
expect(actual).toStrictEqual(expected); | ||
}); | ||
|
||
it('should have a concatenated template description, when the containing stack has an existing desc', () => { | ||
const stackWithDescription = new TestStack(app, 'stackWithDescription', { | ||
systemAdminEmail: '[email protected]', | ||
description: 'ABC', | ||
}); | ||
const actual = stackWithDescription.templateOptions.description; | ||
const expected = 'ABC - SaaS Builder Toolkit - CoreApplicationPlane (uksb-1tupboc57)'; | ||
expect(expected).toStrictEqual(actual); | ||
}); | ||
}); | ||
|
||
describe('ControlPlane cloudwatch roles', () => { | ||
it('should create the cloudwatch IAM apigw push to cw role by default', () => { | ||
const stackWithLogging = new TestStack(new cdk.App(), 'stackWithLogging', { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { App, Stack } from 'aws-cdk-lib'; | ||
import { addTemplateTag } from '../src/utils'; | ||
const app = new App(); | ||
const telemetryConst = 'sbt-aws (uksb-1tupboc57)'; | ||
|
||
describe('addTemplateTag', () => { | ||
it('should append telemetry and tags to existing template description', () => { | ||
const stackA = new Stack(app, 'TestStackA', { description: 'test' }); | ||
const newTag = 'new-tag'; | ||
const expectedDescription = `test - ${telemetryConst} (Tags: new-tag)`; | ||
addTemplateTag(stackA, newTag); | ||
expect(stackA.templateOptions.description).toBe(expectedDescription); | ||
}); | ||
|
||
it('should append a new tag to the description if it does not have any tags', () => { | ||
const stackB = new Stack(app, 'TestStackB'); | ||
const newTag = 'new-tag'; | ||
const expectedDescription = `${telemetryConst} (Tags: new-tag)`; | ||
addTemplateTag(stackB, newTag); | ||
expect(stackB.templateOptions.description).toBe(expectedDescription); | ||
}); | ||
|
||
it('should append a new tag to the existing tags in the description', () => { | ||
const existingDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2)`; | ||
const stackC = new Stack(app, 'TestStackC', { description: existingDescription }); | ||
const newTag = 'new-tag'; | ||
const expectedDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2, new-tag)`; | ||
addTemplateTag(stackC, newTag); | ||
expect(stackC.templateOptions.description).toBe(expectedDescription); | ||
}); | ||
|
||
it('should not append a new tag if it already exists in the description', () => { | ||
const existingDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2, new-tag)`; | ||
const stackD = new Stack(app, 'TestStackD', { description: existingDescription }); | ||
const newTag = 'new-tag'; | ||
const expectedDescription = `This is a sample description - ${telemetryConst} (Tags: tag1, tag2, new-tag)`; | ||
addTemplateTag(stackD, newTag); | ||
expect(stackD.templateOptions.description).toBe(expectedDescription); | ||
}); | ||
}); |