@gradientedge/cdk-utils 9.52.2 → 9.52.3
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/dist/src/lib/azure/services/storage/main.d.ts +26 -0
- package/dist/src/lib/azure/services/storage/main.js +43 -0
- package/dist/src/lib/azure/services/storage/types.d.ts +5 -0
- package/package.json +1 -1
- package/src/lib/azure/services/storage/main.ts +56 -0
- package/src/lib/azure/services/storage/types.ts +7 -1
|
@@ -3,6 +3,7 @@ import { StorageBlob } from '@cdktf/provider-azurerm/lib/storage-blob';
|
|
|
3
3
|
import { StorageContainer } from '@cdktf/provider-azurerm/lib/storage-container';
|
|
4
4
|
import { CommonAzureConstruct } from '../../common';
|
|
5
5
|
import { StorageAccountProps, StorageBlobProps, StorageContainerProps } from './types';
|
|
6
|
+
import { DataAzurermStorageAccountBlobContainerSas } from '@cdktf/provider-azurerm/lib/data-azurerm-storage-account-blob-container-sas';
|
|
6
7
|
/**
|
|
7
8
|
* @classdesc Provides operations on Azure Storage
|
|
8
9
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -45,4 +46,29 @@ export declare class AzureStorageManager {
|
|
|
45
46
|
* @see [CDKTF Storage Blob Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/storageBlob.typescript.md}
|
|
46
47
|
*/
|
|
47
48
|
createStorageBlob(id: string, scope: CommonAzureConstruct, props: StorageBlobProps): StorageBlob;
|
|
49
|
+
/**
|
|
50
|
+
* @summary Generates a container-level SAS token for an existing Azure Storage container.
|
|
51
|
+
*
|
|
52
|
+
* @description
|
|
53
|
+
* This method creates a `DataAzurermStorageAccountBlobContainerSas` resource, allowing secure access
|
|
54
|
+
* to a container via a generated Shared Access Signature (SAS) token.
|
|
55
|
+
*
|
|
56
|
+
* @param id - Unique scoped identifier for the SAS token resource
|
|
57
|
+
* @param scope - CDKTF construct scope in which the resource will be created
|
|
58
|
+
* @param props - Container details and SAS options:
|
|
59
|
+
* - storageAccountName: The name of the existing Azure Storage Account
|
|
60
|
+
* - storageContainerName: The name of the container within the storage account
|
|
61
|
+
* - resourceGroupName: The name of the resource group containing the storage account
|
|
62
|
+
* - sasExpiry: Optional expiry date in the format 'YYYY-MM-DD'. Defaults to 7 days from current date if not provided.
|
|
63
|
+
*
|
|
64
|
+
* @returns A `DataAzurermStorageAccountBlobContainerSas` instance with the generated SAS token
|
|
65
|
+
*
|
|
66
|
+
* @see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account_blob_container_sas
|
|
67
|
+
*/
|
|
68
|
+
generateContainerSasToken(id: string, scope: CommonAzureConstruct, props: {
|
|
69
|
+
storageAccountName: string;
|
|
70
|
+
storageContainerName: string;
|
|
71
|
+
resourceGroupName: string;
|
|
72
|
+
sasExpiry?: string;
|
|
73
|
+
}): DataAzurermStorageAccountBlobContainerSas;
|
|
48
74
|
}
|
|
@@ -8,6 +8,7 @@ const storage_account_1 = require("@cdktf/provider-azurerm/lib/storage-account")
|
|
|
8
8
|
const storage_blob_1 = require("@cdktf/provider-azurerm/lib/storage-blob");
|
|
9
9
|
const storage_container_1 = require("@cdktf/provider-azurerm/lib/storage-container");
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
|
+
const data_azurerm_storage_account_blob_container_sas_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-storage-account-blob-container-sas");
|
|
11
12
|
/**
|
|
12
13
|
* @classdesc Provides operations on Azure Storage
|
|
13
14
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -117,5 +118,47 @@ class AzureStorageManager {
|
|
|
117
118
|
(0, utils_1.createAzureTfOutput)(`${id}-storageBlobId`, scope, storageBlob.id);
|
|
118
119
|
return storageBlob;
|
|
119
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* @summary Generates a container-level SAS token for an existing Azure Storage container.
|
|
123
|
+
*
|
|
124
|
+
* @description
|
|
125
|
+
* This method creates a `DataAzurermStorageAccountBlobContainerSas` resource, allowing secure access
|
|
126
|
+
* to a container via a generated Shared Access Signature (SAS) token.
|
|
127
|
+
*
|
|
128
|
+
* @param id - Unique scoped identifier for the SAS token resource
|
|
129
|
+
* @param scope - CDKTF construct scope in which the resource will be created
|
|
130
|
+
* @param props - Container details and SAS options:
|
|
131
|
+
* - storageAccountName: The name of the existing Azure Storage Account
|
|
132
|
+
* - storageContainerName: The name of the container within the storage account
|
|
133
|
+
* - resourceGroupName: The name of the resource group containing the storage account
|
|
134
|
+
* - sasExpiry: Optional expiry date in the format 'YYYY-MM-DD'. Defaults to 7 days from current date if not provided.
|
|
135
|
+
*
|
|
136
|
+
* @returns A `DataAzurermStorageAccountBlobContainerSas` instance with the generated SAS token
|
|
137
|
+
*
|
|
138
|
+
* @see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account_blob_container_sas
|
|
139
|
+
*/
|
|
140
|
+
generateContainerSasToken(id, scope, props) {
|
|
141
|
+
const storageAccountLookup = new data_azurerm_storage_account_1.DataAzurermStorageAccount(scope, `${id}-lookup-sa`, {
|
|
142
|
+
name: props.storageAccountName,
|
|
143
|
+
resourceGroupName: props.resourceGroupName,
|
|
144
|
+
});
|
|
145
|
+
const containerSas = new data_azurerm_storage_account_blob_container_sas_1.DataAzurermStorageAccountBlobContainerSas(scope, `${id}-sas`, {
|
|
146
|
+
connectionString: storageAccountLookup.primaryConnectionString,
|
|
147
|
+
containerName: props.storageContainerName,
|
|
148
|
+
httpsOnly: true,
|
|
149
|
+
start: new Date().toISOString().split('T')[0],
|
|
150
|
+
expiry: props.sasExpiry ?? new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
|
151
|
+
permissions: {
|
|
152
|
+
read: true,
|
|
153
|
+
add: false,
|
|
154
|
+
create: false,
|
|
155
|
+
delete: false,
|
|
156
|
+
list: false,
|
|
157
|
+
write: false,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
(0, utils_1.createAzureTfOutput)(`${id}-sas-token`, scope, containerSas.sas, 'output', true);
|
|
161
|
+
return containerSas;
|
|
162
|
+
}
|
|
120
163
|
}
|
|
121
164
|
exports.AzureStorageManager = AzureStorageManager;
|
|
@@ -7,4 +7,9 @@ export interface StorageAccountProps extends StorageAccountConfig {
|
|
|
7
7
|
export interface StorageContainerProps extends BaseAzureConfigProps, StorageContainerConfig {
|
|
8
8
|
}
|
|
9
9
|
export interface StorageBlobProps extends BaseAzureConfigProps, StorageBlobConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Optional ISO date string representing the expiry date for the SAS token.
|
|
12
|
+
* Format: 'YYYY-MM-DD' (e.g., '2025-05-01')
|
|
13
|
+
*/
|
|
14
|
+
sasExpiry?: string;
|
|
10
15
|
}
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { StorageContainer } from '@cdktf/provider-azurerm/lib/storage-container'
|
|
|
7
7
|
import { CommonAzureConstruct } from '../../common'
|
|
8
8
|
import { createAzureTfOutput } from '../../utils'
|
|
9
9
|
import { StorageAccountProps, StorageBlobProps, StorageContainerProps } from './types'
|
|
10
|
+
import { DataAzurermStorageAccountBlobContainerSas } from '@cdktf/provider-azurerm/lib/data-azurerm-storage-account-blob-container-sas'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @classdesc Provides operations on Azure Storage
|
|
@@ -129,4 +130,59 @@ export class AzureStorageManager {
|
|
|
129
130
|
|
|
130
131
|
return storageBlob
|
|
131
132
|
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @summary Generates a container-level SAS token for an existing Azure Storage container.
|
|
136
|
+
*
|
|
137
|
+
* @description
|
|
138
|
+
* This method creates a `DataAzurermStorageAccountBlobContainerSas` resource, allowing secure access
|
|
139
|
+
* to a container via a generated Shared Access Signature (SAS) token.
|
|
140
|
+
*
|
|
141
|
+
* @param id - Unique scoped identifier for the SAS token resource
|
|
142
|
+
* @param scope - CDKTF construct scope in which the resource will be created
|
|
143
|
+
* @param props - Container details and SAS options:
|
|
144
|
+
* - storageAccountName: The name of the existing Azure Storage Account
|
|
145
|
+
* - storageContainerName: The name of the container within the storage account
|
|
146
|
+
* - resourceGroupName: The name of the resource group containing the storage account
|
|
147
|
+
* - sasExpiry: Optional expiry date in the format 'YYYY-MM-DD'. Defaults to 7 days from current date if not provided.
|
|
148
|
+
*
|
|
149
|
+
* @returns A `DataAzurermStorageAccountBlobContainerSas` instance with the generated SAS token
|
|
150
|
+
*
|
|
151
|
+
* @see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account_blob_container_sas
|
|
152
|
+
*/
|
|
153
|
+
public generateContainerSasToken(
|
|
154
|
+
id: string,
|
|
155
|
+
scope: CommonAzureConstruct,
|
|
156
|
+
props: {
|
|
157
|
+
storageAccountName: string
|
|
158
|
+
storageContainerName: string
|
|
159
|
+
resourceGroupName: string
|
|
160
|
+
sasExpiry?: string
|
|
161
|
+
}
|
|
162
|
+
): DataAzurermStorageAccountBlobContainerSas {
|
|
163
|
+
const storageAccountLookup = new DataAzurermStorageAccount(scope, `${id}-lookup-sa`, {
|
|
164
|
+
name: props.storageAccountName,
|
|
165
|
+
resourceGroupName: props.resourceGroupName,
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const containerSas = new DataAzurermStorageAccountBlobContainerSas(scope, `${id}-sas`, {
|
|
169
|
+
connectionString: storageAccountLookup.primaryConnectionString,
|
|
170
|
+
containerName: props.storageContainerName,
|
|
171
|
+
httpsOnly: true,
|
|
172
|
+
start: new Date().toISOString().split('T')[0],
|
|
173
|
+
expiry: props.sasExpiry ?? new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
|
174
|
+
permissions: {
|
|
175
|
+
read: true,
|
|
176
|
+
add: false,
|
|
177
|
+
create: false,
|
|
178
|
+
delete: false,
|
|
179
|
+
list: false,
|
|
180
|
+
write: false,
|
|
181
|
+
},
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
createAzureTfOutput(`${id}-sas-token`, scope, containerSas.sas, 'output', true)
|
|
185
|
+
|
|
186
|
+
return containerSas
|
|
187
|
+
}
|
|
132
188
|
}
|
|
@@ -7,4 +7,10 @@ export interface StorageAccountProps extends StorageAccountConfig {}
|
|
|
7
7
|
|
|
8
8
|
export interface StorageContainerProps extends BaseAzureConfigProps, StorageContainerConfig {}
|
|
9
9
|
|
|
10
|
-
export interface StorageBlobProps extends BaseAzureConfigProps, StorageBlobConfig {
|
|
10
|
+
export interface StorageBlobProps extends BaseAzureConfigProps, StorageBlobConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Optional ISO date string representing the expiry date for the SAS token.
|
|
13
|
+
* Format: 'YYYY-MM-DD' (e.g., '2025-05-01')
|
|
14
|
+
*/
|
|
15
|
+
sasExpiry?: string
|
|
16
|
+
}
|