|
9 | 9 | TagName,
|
10 | 10 | } from '@aws-amplify/platform-core';
|
11 | 11 | import {
|
| 12 | + AmplifyResourceGroupName, |
12 | 13 | BackendOutputStorageStrategy,
|
13 | 14 | BackendSecret,
|
14 | 15 | BackendSecretResolver,
|
@@ -150,6 +151,14 @@ export type FunctionProps = {
|
150 | 151 | * Options for bundling the function code.
|
151 | 152 | */
|
152 | 153 | bundling?: FunctionBundlingOptions;
|
| 154 | + |
| 155 | + /** |
| 156 | + * Group the function with existing Amplify resources or separate the function into its own group. |
| 157 | + * @default 'function' // grouping with other Amplify functions |
| 158 | + * @example |
| 159 | + * resourceGroupName: 'auth' // to group an auth trigger with an auth resource |
| 160 | + */ |
| 161 | + resourceGroupName?: AmplifyResourceGroupName; |
153 | 162 | };
|
154 | 163 |
|
155 | 164 | export type FunctionBundlingOptions = {
|
@@ -208,6 +217,7 @@ class FunctionFactory implements ConstructFactory<AmplifyFunction> {
|
208 | 217 | schedule: this.resolveSchedule(),
|
209 | 218 | bundling: this.resolveBundling(),
|
210 | 219 | layers,
|
| 220 | + resourceGroupName: this.props.resourceGroupName ?? 'function', |
211 | 221 | };
|
212 | 222 | };
|
213 | 223 |
|
@@ -339,12 +349,14 @@ class FunctionFactory implements ConstructFactory<AmplifyFunction> {
|
339 | 349 | type HydratedFunctionProps = Required<FunctionProps>;
|
340 | 350 |
|
341 | 351 | class FunctionGenerator implements ConstructContainerEntryGenerator {
|
342 |
| - readonly resourceGroupName = 'function'; |
| 352 | + readonly resourceGroupName: AmplifyResourceGroupName; |
343 | 353 |
|
344 | 354 | constructor(
|
345 | 355 | private readonly props: HydratedFunctionProps,
|
346 | 356 | private readonly outputStorageStrategy: BackendOutputStorageStrategy<FunctionOutput>
|
347 |
| - ) {} |
| 357 | + ) { |
| 358 | + this.resourceGroupName = props.resourceGroupName; |
| 359 | + } |
348 | 360 |
|
349 | 361 | generateContainerEntry = ({
|
350 | 362 | scope,
|
|
0 commit comments