@gradientedge/cdk-utils 8.121.0 → 8.123.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/src/lib/aws/common/construct.d.ts +0 -1
- package/dist/src/lib/aws/common/construct.js +6 -13
- package/dist/src/lib/aws/common/stack.js +7 -9
- package/dist/src/lib/aws/common/types.d.ts +2 -8
- package/dist/src/lib/aws/construct/api-to-any-target/main.js +24 -26
- package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +85 -103
- package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +94 -120
- package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +8 -10
- package/dist/src/lib/aws/construct/graphql-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +5 -1
- package/dist/src/lib/aws/construct/rest-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/rest-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +8 -6
- package/dist/src/lib/aws/construct/static-asset-deployment/main.js +5 -1
- package/dist/src/lib/aws/services/api-gateway/main.js +18 -10
- package/dist/src/lib/aws/services/cloudfront/main.js +11 -7
- package/dist/src/lib/aws/services/cloudwatch/logs.js +8 -4
- package/dist/src/lib/aws/services/cloudwatch/main.js +36 -78
- package/dist/src/lib/aws/services/dynamodb/main.js +6 -2
- package/dist/src/lib/aws/services/elastic-container-service/main.js +8 -4
- package/dist/src/lib/aws/services/elastic-file-system/main.js +5 -1
- package/dist/src/lib/aws/services/elasticache/main.js +6 -2
- package/dist/src/lib/aws/services/eventbridge/main.js +8 -4
- package/dist/src/lib/aws/services/lambda/main.js +7 -3
- package/dist/src/lib/aws/services/simple-notification-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-queue-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-storage-service/main.js +8 -4
- package/dist/src/lib/aws/services/step-function/main.js +52 -32
- package/dist/src/lib/aws/services/virtual-private-cloud/main.js +8 -4
- package/dist/src/lib/aws/types/index.d.ts +6 -1
- package/dist/src/lib/aws/types/index.js +0 -15
- package/dist/src/lib/aws/utils/index.d.ts +13 -23
- package/dist/src/lib/aws/utils/index.js +37 -46
- package/dist/src/lib/azure/common/construct.d.ts +35 -0
- package/dist/src/lib/azure/common/construct.js +49 -0
- package/dist/src/lib/azure/common/index.d.ts +3 -0
- package/dist/src/lib/azure/common/index.js +19 -0
- package/dist/src/lib/azure/common/stack.d.ts +52 -0
- package/dist/src/lib/azure/common/stack.js +134 -0
- package/dist/src/lib/azure/common/types.d.ts +7 -0
- package/dist/src/lib/azure/index.d.ts +4 -0
- package/dist/src/lib/azure/index.js +20 -0
- package/dist/src/lib/azure/services/index.d.ts +1 -0
- package/dist/src/lib/azure/services/index.js +17 -0
- package/dist/src/lib/azure/services/storage/index.d.ts +2 -0
- package/dist/src/lib/azure/services/storage/index.js +18 -0
- package/dist/src/lib/azure/services/storage/main.d.ts +43 -0
- package/dist/src/lib/azure/services/storage/main.js +124 -0
- package/dist/src/lib/azure/services/storage/types.d.ts +10 -0
- package/dist/src/lib/azure/services/storage/types.js +2 -0
- package/dist/src/lib/azure/types/index.d.ts +3 -0
- package/dist/src/lib/azure/types/index.js +2 -0
- package/dist/src/lib/azure/utils/index.d.ts +3 -0
- package/dist/src/lib/azure/utils/index.js +20 -0
- package/dist/src/lib/common/construct.d.ts +29 -0
- package/dist/src/lib/common/construct.js +8 -0
- package/dist/src/lib/common/index.d.ts +5 -0
- package/dist/src/lib/common/index.js +33 -0
- package/dist/src/lib/common/stack.d.ts +21 -0
- package/dist/src/lib/common/stack.js +8 -0
- package/dist/src/lib/common/types.d.ts +9 -0
- package/dist/src/lib/common/types.js +2 -0
- package/dist/src/lib/common/utils.d.ts +26 -0
- package/dist/src/lib/common/utils.js +34 -0
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/index.js +2 -0
- package/package.json +9 -7
- package/setup.js +2 -0
- package/src/lib/aws/common/construct.ts +2 -13
- package/src/lib/aws/common/stack.ts +6 -8
- package/src/lib/aws/common/types.ts +2 -8
- package/src/lib/aws/construct/api-to-any-target/main.ts +25 -27
- package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +85 -103
- package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +94 -120
- package/src/lib/aws/construct/api-to-lambda-target/main.ts +8 -10
- package/src/lib/aws/construct/graphql-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/graphql-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/lambda-with-iam-access/main.ts +2 -1
- package/src/lib/aws/construct/rest-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/rest-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/site-with-ecs-backend/main.ts +8 -9
- package/src/lib/aws/construct/static-asset-deployment/main.ts +2 -1
- package/src/lib/aws/services/api-gateway/main.ts +9 -6
- package/src/lib/aws/services/cloudfront/main.ts +8 -7
- package/src/lib/aws/services/cloudwatch/logs.ts +6 -5
- package/src/lib/aws/services/cloudwatch/main.ts +35 -81
- package/src/lib/aws/services/dynamodb/main.ts +3 -2
- package/src/lib/aws/services/elastic-container-service/main.ts +5 -4
- package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
- package/src/lib/aws/services/elasticache/main.ts +3 -2
- package/src/lib/aws/services/eventbridge/main.ts +5 -4
- package/src/lib/aws/services/lambda/main.ts +4 -3
- package/src/lib/aws/services/simple-notification-service/main.ts +3 -2
- package/src/lib/aws/services/simple-queue-service/main.ts +3 -2
- package/src/lib/aws/services/simple-storage-service/main.ts +5 -4
- package/src/lib/aws/services/step-function/main.ts +17 -16
- package/src/lib/aws/services/virtual-private-cloud/main.ts +5 -4
- package/src/lib/aws/types/index.ts +6 -1
- package/src/lib/aws/utils/index.ts +41 -29
- package/src/lib/azure/common/construct.ts +57 -0
- package/src/lib/azure/common/index.ts +3 -0
- package/src/lib/azure/common/stack.ts +143 -0
- package/src/lib/azure/common/types.ts +8 -0
- package/src/lib/azure/index.ts +4 -0
- package/src/lib/azure/services/index.ts +1 -0
- package/src/lib/azure/services/storage/index.ts +2 -0
- package/src/lib/azure/services/storage/main.ts +134 -0
- package/src/lib/azure/services/storage/types.ts +10 -0
- package/src/lib/azure/types/index.ts +3 -0
- package/src/lib/azure/utils/index.ts +23 -0
- package/src/lib/common/construct.ts +35 -0
- package/src/lib/common/index.ts +18 -0
- package/src/lib/common/stack.ts +26 -0
- package/src/lib/common/types.ts +9 -0
- package/src/lib/common/utils.ts +27 -0
- package/src/lib/index.ts +2 -0
- package/dist/src/lib/aws/types/aws/index.d.ts +0 -6
- package/dist/src/lib/aws/utils/aws/index.d.ts +0 -17
- package/dist/src/lib/aws/utils/aws/index.js +0 -40
- package/src/lib/aws/types/aws/index.ts +0 -6
- package/src/lib/aws/utils/aws/index.ts +0 -41
- /package/dist/src/lib/{aws/types/aws/index.js → azure/common/types.js} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
|
|
2
|
+
import { DataAzurermStorageAccount } from '@cdktf/provider-azurerm/lib/data-azurerm-storage-account'
|
|
3
|
+
import { DataAzurermStorageContainer } from '@cdktf/provider-azurerm/lib/data-azurerm-storage-container'
|
|
4
|
+
import { StorageAccount } from '@cdktf/provider-azurerm/lib/storage-account'
|
|
5
|
+
import { StorageBlob } from '@cdktf/provider-azurerm/lib/storage-blob'
|
|
6
|
+
import { StorageContainer } from '@cdktf/provider-azurerm/lib/storage-container'
|
|
7
|
+
import { CommonAzureConstruct } from '../../common'
|
|
8
|
+
import { createTfOutput } from '../../utils'
|
|
9
|
+
import { StorageAccountProps, StorageBlobProps, StorageContainerProps } from './types'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @classdesc Provides operations on Azure Storage
|
|
13
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
14
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
18
|
+
*
|
|
19
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
20
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
21
|
+
* super(parent, id, props)
|
|
22
|
+
* this.props = props
|
|
23
|
+
* this.storageManager.createStorageAccount('MyAccount', this, props)
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* @see [CDKTF S3 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3-readme.html}
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export class AzureStorageManager {
|
|
30
|
+
/**
|
|
31
|
+
* @summary Method to create a new storage account
|
|
32
|
+
* @param id scoped id of the resource
|
|
33
|
+
* @param scope scope in which this resource is defined
|
|
34
|
+
* @param props storage account properties
|
|
35
|
+
*/
|
|
36
|
+
public createStorageAccount(id: string, scope: CommonAzureConstruct, props: StorageAccountProps) {
|
|
37
|
+
if (!props) throw `Props undefined for ${id}`
|
|
38
|
+
|
|
39
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
40
|
+
name: scope.props.resourceGroupName
|
|
41
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
42
|
+
: `${props.resourceGroupName}-${scope.props.stage}`,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
46
|
+
|
|
47
|
+
const storageAccount = new StorageAccount(scope, `${id}-sa`, {
|
|
48
|
+
...props,
|
|
49
|
+
accountTier: props.accountTier ?? 'Standard',
|
|
50
|
+
location: props.location ?? resourceGroup.location,
|
|
51
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
52
|
+
resourceGroupName: resourceGroup.name,
|
|
53
|
+
tags: props.tags ?? {
|
|
54
|
+
environment: scope.props.stage,
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
createTfOutput(`${id}-storageAccountName`, scope, storageAccount.name)
|
|
59
|
+
createTfOutput(`${id}-storageAccountFriendlyUniqueId`, scope, storageAccount.friendlyUniqueId)
|
|
60
|
+
createTfOutput(`${id}-storageAccountId`, scope, storageAccount.id)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @summary Method to create a new storage container
|
|
65
|
+
* @param id scoped id of the resource
|
|
66
|
+
* @param scope scope in which this resource is defined
|
|
67
|
+
* @param props storage container properties
|
|
68
|
+
*/
|
|
69
|
+
public createStorageContainer(id: string, scope: CommonAzureConstruct, props: StorageContainerProps) {
|
|
70
|
+
if (!props) throw `Props undefined for ${id}`
|
|
71
|
+
|
|
72
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
73
|
+
name: scope.props.resourceGroupName
|
|
74
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
75
|
+
: `${props.resourceGroupName}-${scope.props.stage}`,
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
79
|
+
|
|
80
|
+
const storageAccount = new DataAzurermStorageAccount(scope, `${id}-sa`, {
|
|
81
|
+
name: `${props.storageAccountName}-${scope.props.stage}`,
|
|
82
|
+
resourceGroupName: resourceGroup.name,
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const storageContainer = new StorageContainer(scope, `${id}-sc`, {
|
|
86
|
+
...props,
|
|
87
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
88
|
+
storageAccountName: storageAccount.name,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
createTfOutput(`${id}-storageContainerName`, scope, storageContainer.name)
|
|
92
|
+
createTfOutput(`${id}-storageContainerFriendlyUniqueId`, scope, storageContainer.friendlyUniqueId)
|
|
93
|
+
createTfOutput(`${id}-storageContainerId`, scope, storageContainer.id)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @summary Method to create a new storage blob
|
|
98
|
+
* @param id scoped id of the resource
|
|
99
|
+
* @param scope scope in which this resource is defined
|
|
100
|
+
* @param props storage blob properties
|
|
101
|
+
*/
|
|
102
|
+
public createStorageBlob(id: string, scope: CommonAzureConstruct, props: StorageBlobProps) {
|
|
103
|
+
if (!props) throw `Props undefined for ${id}`
|
|
104
|
+
|
|
105
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
|
|
106
|
+
name: scope.props.resourceGroupName
|
|
107
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
108
|
+
: `${props.resourceGroupName}-${scope.props.stage}`,
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
112
|
+
|
|
113
|
+
const storageAccount = new DataAzurermStorageAccount(scope, `${id}-sa`, {
|
|
114
|
+
name: `${props.storageAccountName}-${scope.props.stage}`,
|
|
115
|
+
resourceGroupName: resourceGroup.name,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const storageContainer = new DataAzurermStorageContainer(scope, `${id}-sc`, {
|
|
119
|
+
name: `${props.storageContainerName}-${scope.props.stage}`,
|
|
120
|
+
storageAccountName: storageAccount.name,
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const storageBlob = new StorageBlob(scope, `${id}-sb`, {
|
|
124
|
+
...props,
|
|
125
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
126
|
+
storageAccountName: storageAccount.name,
|
|
127
|
+
storageContainerName: storageContainer.name,
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
createTfOutput(`${id}-storageBlobName`, scope, storageBlob.name)
|
|
131
|
+
createTfOutput(`${id}-storageBlobFriendlyUniqueId`, scope, storageBlob.friendlyUniqueId)
|
|
132
|
+
createTfOutput(`${id}-storageBlobId`, scope, storageBlob.id)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StorageAccountConfig } from '@cdktf/provider-azurerm/lib/storage-account'
|
|
2
|
+
import { StorageBlobConfig } from '@cdktf/provider-azurerm/lib/storage-blob'
|
|
3
|
+
import { StorageContainerConfig } from '@cdktf/provider-azurerm/lib/storage-container'
|
|
4
|
+
import { BaseConfigProps } from '../../types'
|
|
5
|
+
|
|
6
|
+
export interface StorageAccountProps extends StorageAccountConfig {}
|
|
7
|
+
|
|
8
|
+
export interface StorageContainerProps extends BaseConfigProps, StorageContainerConfig {}
|
|
9
|
+
|
|
10
|
+
export interface StorageBlobProps extends BaseConfigProps, StorageBlobConfig {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TerraformOutput } from 'cdktf'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
import { CommonAzureConstruct } from '../common'
|
|
4
|
+
|
|
5
|
+
export const createTfOutput = (
|
|
6
|
+
id: string,
|
|
7
|
+
scope: CommonAzureConstruct,
|
|
8
|
+
value?: string,
|
|
9
|
+
description?: string,
|
|
10
|
+
sensitive?: boolean,
|
|
11
|
+
overrideId = true
|
|
12
|
+
) => {
|
|
13
|
+
const output = new TerraformOutput(scope, id, {
|
|
14
|
+
description,
|
|
15
|
+
sensitive,
|
|
16
|
+
value,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
if (overrideId) {
|
|
20
|
+
output.overrideLogicalId(_.camelCase(id))
|
|
21
|
+
}
|
|
22
|
+
return output
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Construct } from 'constructs'
|
|
2
|
+
import { BaseProps } from './types'
|
|
3
|
+
|
|
4
|
+
export abstract class BaseConstruct extends Construct {
|
|
5
|
+
props: BaseProps
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
9
|
+
*/
|
|
10
|
+
public abstract determineFullyQualifiedDomain(): void
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
14
|
+
* This is determined by the stage property injected via cdk context
|
|
15
|
+
*/
|
|
16
|
+
public abstract isDevelopmentStage(): void
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @summary Utility method to determine if the initialisation is in test (tst) stage
|
|
20
|
+
* This is determined by the stage property injected via cdk context
|
|
21
|
+
*/
|
|
22
|
+
public abstract isTestStage(): void
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @summary Utility method to determine if the initialisation is in uat (uat) stage
|
|
26
|
+
* This is determined by the stage property injected via cdk context
|
|
27
|
+
*/
|
|
28
|
+
public abstract isUatStage(): void
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @summary Utility method to determine if the initialisation is in production (prd) stage
|
|
32
|
+
* This is determined by the stage property injected via cdk context
|
|
33
|
+
*/
|
|
34
|
+
public abstract isProductionStage(): void
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
|
|
3
|
+
export * from './construct'
|
|
4
|
+
export * from './stack'
|
|
5
|
+
export * from './types'
|
|
6
|
+
export * from './utils'
|
|
7
|
+
|
|
8
|
+
export const applyMixins = (derivedCtor: any, constructors: any[]) => {
|
|
9
|
+
_.forEach(constructors, baseConstructor => {
|
|
10
|
+
Object.getOwnPropertyNames(baseConstructor.prototype).forEach(name => {
|
|
11
|
+
Object.defineProperty(
|
|
12
|
+
derivedCtor.prototype,
|
|
13
|
+
name,
|
|
14
|
+
Object.getOwnPropertyDescriptor(baseConstructor.prototype, name) || Object.create(null)
|
|
15
|
+
)
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Construct } from 'constructs'
|
|
2
|
+
import { BaseProps } from './types'
|
|
3
|
+
|
|
4
|
+
export abstract class BaseStack extends Construct {
|
|
5
|
+
props: BaseProps
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @summary Method to determine the core CDK construct properties injected via context cdktf.json
|
|
9
|
+
*/
|
|
10
|
+
protected abstract determineConstructProps(props: BaseProps): void
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @summary Method to determine extra cdk contexts apart from the main cdktf.json
|
|
14
|
+
*/
|
|
15
|
+
public abstract determineExtraContexts(): void
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
|
|
19
|
+
*/
|
|
20
|
+
public abstract determineStageContexts(): void
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
24
|
+
*/
|
|
25
|
+
public abstract fullyQualifiedDomain(): void
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*/
|
|
3
|
+
export enum LogLevel {
|
|
4
|
+
DEBUG = 'DEBUG',
|
|
5
|
+
INFO = 'INFO',
|
|
6
|
+
WARNING = 'WARNING',
|
|
7
|
+
TRACE = 'TRACE',
|
|
8
|
+
ERROR = 'ERROR',
|
|
9
|
+
CRITICAL = 'CRITICAL',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param stage
|
|
14
|
+
*/
|
|
15
|
+
export const isDevStage = (stage: string) => stage === 'dev'
|
|
16
|
+
/**
|
|
17
|
+
* @param stage
|
|
18
|
+
*/
|
|
19
|
+
export const isTestStage = (stage: string) => stage === 'tst'
|
|
20
|
+
/**
|
|
21
|
+
* @param stage
|
|
22
|
+
*/
|
|
23
|
+
export const isUatStage = (stage: string) => stage === 'uat'
|
|
24
|
+
/**
|
|
25
|
+
* @param stage
|
|
26
|
+
*/
|
|
27
|
+
export const isPrdStage = (stage: string) => stage === 'prd'
|
package/src/lib/index.ts
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
|
|
2
|
-
import { CfnOutput } from 'aws-cdk-lib';
|
|
3
|
-
import { CommonConstruct } from '../../common';
|
|
4
|
-
/**
|
|
5
|
-
* @summary Helper method to add CloudFormation outputs from the construct
|
|
6
|
-
* @param id scoped id of the resource
|
|
7
|
-
* @param scope scope in which this resource is defined
|
|
8
|
-
* @param value the value of the exported output
|
|
9
|
-
* @param description optional description for the output
|
|
10
|
-
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
11
|
-
* @returns The CloudFormation output
|
|
12
|
-
*/
|
|
13
|
-
export declare function createCfnOutput(id: string, scope: CommonConstruct, value?: string, description?: string, overrideId?: boolean): CfnOutput;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare function determineCredentials(): AwsCredentialIdentityProvider;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.determineCredentials = exports.createCfnOutput = void 0;
|
|
7
|
-
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
8
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
9
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
/**
|
|
11
|
-
* @summary Helper method to add CloudFormation outputs from the construct
|
|
12
|
-
* @param id scoped id of the resource
|
|
13
|
-
* @param scope scope in which this resource is defined
|
|
14
|
-
* @param value the value of the exported output
|
|
15
|
-
* @param description optional description for the output
|
|
16
|
-
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
17
|
-
* @returns The CloudFormation output
|
|
18
|
-
*/
|
|
19
|
-
function createCfnOutput(id, scope, value, description, overrideId = true) {
|
|
20
|
-
const camelName = lodash_1.default.camelCase(id);
|
|
21
|
-
const output = new aws_cdk_lib_1.CfnOutput(scope, id, {
|
|
22
|
-
description,
|
|
23
|
-
exportName: `${scope.props.stackName}-${camelName}`,
|
|
24
|
-
value: value ?? '',
|
|
25
|
-
});
|
|
26
|
-
if (overrideId) {
|
|
27
|
-
output.overrideLogicalId(camelName);
|
|
28
|
-
}
|
|
29
|
-
return output;
|
|
30
|
-
}
|
|
31
|
-
exports.createCfnOutput = createCfnOutput;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
function determineCredentials() {
|
|
36
|
-
if (process.env.AWS_PROFILE)
|
|
37
|
-
return (0, credential_providers_1.fromIni)();
|
|
38
|
-
return (0, credential_providers_1.fromEnv)();
|
|
39
|
-
}
|
|
40
|
-
exports.determineCredentials = determineCredentials;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { fromEnv, fromIni } from '@aws-sdk/credential-providers'
|
|
2
|
-
import { AwsCredentialIdentityProvider } from '@aws-sdk/types'
|
|
3
|
-
import { CfnOutput } from 'aws-cdk-lib'
|
|
4
|
-
import _ from 'lodash'
|
|
5
|
-
import { CommonConstruct } from '../../common'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @summary Helper method to add CloudFormation outputs from the construct
|
|
9
|
-
* @param id scoped id of the resource
|
|
10
|
-
* @param scope scope in which this resource is defined
|
|
11
|
-
* @param value the value of the exported output
|
|
12
|
-
* @param description optional description for the output
|
|
13
|
-
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
14
|
-
* @returns The CloudFormation output
|
|
15
|
-
*/
|
|
16
|
-
export function createCfnOutput(
|
|
17
|
-
id: string,
|
|
18
|
-
scope: CommonConstruct,
|
|
19
|
-
value?: string,
|
|
20
|
-
description?: string,
|
|
21
|
-
overrideId = true
|
|
22
|
-
): CfnOutput {
|
|
23
|
-
const camelName = _.camelCase(id)
|
|
24
|
-
const output = new CfnOutput(scope, id, {
|
|
25
|
-
description,
|
|
26
|
-
exportName: `${scope.props.stackName}-${camelName}`,
|
|
27
|
-
value: value ?? '',
|
|
28
|
-
})
|
|
29
|
-
if (overrideId) {
|
|
30
|
-
output.overrideLogicalId(camelName)
|
|
31
|
-
}
|
|
32
|
-
return output
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
export function determineCredentials(): AwsCredentialIdentityProvider {
|
|
39
|
-
if (process.env.AWS_PROFILE) return fromIni()
|
|
40
|
-
return fromEnv()
|
|
41
|
-
}
|
|
File without changes
|