Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
003a66c
test with adding tags
Sep 16, 2024
f71e369
testing stack change
Sep 16, 2024
2bfd1d6
implementation attempts
Sep 17, 2024
0724043
Merge branch 'main' into resource-tags
Sep 17, 2024
32faeb5
revert accidental package-lock change
Sep 18, 2024
a84e29c
added stack param to function resource
Sep 18, 2024
c9f4c76
Merge branch 'main' into resource-tags
Sep 18, 2024
e937738
added changeset
Sep 18, 2024
80c981e
api updates
Sep 18, 2024
944c26a
Revert "api updates"
Sep 18, 2024
fee57b0
adjusted getting stack param for auth
Sep 18, 2024
4242f83
Merge branch 'main' into resource-tags
Sep 18, 2024
432e144
attempt to fix auth stack param
Sep 18, 2024
7c3605a
Merge branch 'main' into resource-tags
Sep 18, 2024
79678cc
api updates
Sep 18, 2024
70c6c58
trying to make api happy
Sep 18, 2024
29e3daf
Revert "api updates"
Sep 18, 2024
06e780d
removed comment
Sep 18, 2024
dd80c05
update to exposed stack for auth, function, and backend
Sep 18, 2024
1bb5991
exposed stack for storage
Sep 18, 2024
2f52020
Merge branch 'main' into resource-tags
Sep 18, 2024
37fceff
update changesets
Sep 18, 2024
4f59c17
updated storage stack param
Sep 19, 2024
5f3f26c
api updates
Sep 19, 2024
bc2b992
added tests to backend, auth, storage, and function
Sep 19, 2024
135aa80
updated factory tests for function
Sep 19, 2024
5d339db
updates to factory test for auth
Sep 19, 2024
7ccbcf1
updates to api
Sep 19, 2024
a228c6a
Merge branch 'main' into resource-tags
Sep 19, 2024
88b84d9
trying to make api happy
Sep 19, 2024
28d00be
stack parameter exposed for data
Sep 19, 2024
59257d4
updated changeset
Sep 19, 2024
558692f
api update
Sep 19, 2024
ae59615
reverted exposing stack param for data
Sep 19, 2024
4a5cbf4
Revert "api update"
Sep 19, 2024
6490c63
removed changeset that is not needed
Sep 19, 2024
4d27d77
Update .changeset/chatty-beans-begin.md
ShadowCat567 Sep 19, 2024
077eed8
Merge branch 'main' into resource-tags
Sep 19, 2024
0f8ed88
update changeset, variable name changes
Sep 19, 2024
4b0182e
altered changeset
Sep 19, 2024
24eff8a
minor adjustment to backend-function factory test
Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/chatty-beans-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@aws-amplify/backend-function': minor
'@aws-amplify/backend-auth': minor
'@aws-amplify/backend': minor
---

expose stack parameter for backend, function resource, and auth resource
15 changes: 12 additions & 3 deletions packages/backend-auth/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ import {
Expand,
} from './types.js';
import { UserPoolAccessPolicyFactory } from './userpool_access_policy_factory.js';
import { Tags } from 'aws-cdk-lib';
import { Stack, Tags } from 'aws-cdk-lib';

export type BackendAuth = ResourceProvider<AuthResources> &
ResourceAccessAcceptorFactory<AuthRoleName | string>;
ResourceAccessAcceptorFactory<AuthRoleName | string> &
AuthStackFactory;

export type AuthStackFactory = {
stack: Stack;
};

export type AmplifyAuthProps = Expand<
Omit<AuthProps, 'outputStorageStrategy' | 'loginWith'> & {
Expand Down Expand Up @@ -115,7 +120,10 @@ export class AmplifyAuthFactory implements ConstructFactory<BackendAuth> {
};
}

class AmplifyAuthGenerator implements ConstructContainerEntryGenerator {
class AmplifyAuthGenerator
implements ConstructContainerEntryGenerator, AuthStackFactory
{
stack: Stack;
readonly resourceGroupName = 'auth';
private readonly name: string;

Expand Down Expand Up @@ -195,6 +203,7 @@ class AmplifyAuthGenerator implements ConstructContainerEntryGenerator {
policy.attachToRole(role);
},
}),
stack: Stack.of(this.generateContainerEntry.prototype),
};
if (!this.props.access) {
return authConstructMixin;
Expand Down
13 changes: 11 additions & 2 deletions packages/backend-function/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export type AddEnvironmentFactory = {
addEnvironment: (key: string, value: string | BackendSecret) => void;
};

export type FuncStackFactory = {
stack: Stack;
};

export type CronSchedule =
| `${string} ${string} ${string} ${string} ${string}`
| `${string} ${string} ${string} ${string} ${string} ${string}`;
Expand All @@ -64,7 +68,8 @@ export const defineFunction = (
): ConstructFactory<
ResourceProvider<FunctionResources> &
ResourceAccessAcceptorFactory &
AddEnvironmentFactory
AddEnvironmentFactory &
FuncStackFactory
> => new FunctionFactory(props, new Error().stack);

export type FunctionProps = {
Expand Down Expand Up @@ -305,8 +310,10 @@ class AmplifyFunction
implements
ResourceProvider<FunctionResources>,
ResourceAccessAcceptorFactory,
AddEnvironmentFactory
AddEnvironmentFactory,
FuncStackFactory
{
stack: Stack;
readonly resources: FunctionResources;
private readonly functionEnvironmentTranslator: FunctionEnvironmentTranslator;
constructor(
Expand Down Expand Up @@ -443,6 +450,8 @@ class AmplifyFunction
functionStackType,
fileURLToPath(new URL('../package.json', import.meta.url))
);

this.stack = Stack.of(this);
}

addEnvironment = (key: string, value: string | BackendSecret) => {
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type BackendBase = {
addOutput: (
clientConfigPart: DeepPartialAmplifyGeneratedConfigs<ClientConfig>
) => void;
stack: () => Stack;
};

// Type that allows construct factories to be defined using any keys except those used in BackendHelpers
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/backend_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ export class BackendFactory<
}
this.customOutputsAccumulator.addOutput(clientConfigPart);
};

rootStack = (): Stack => {
return this.stackResolver.getStackFor('root');
};
}

/**
Expand All @@ -157,5 +161,6 @@ export const defineBackend = <T extends DefineBackendProps>(
...backend.resources,
createStack: backend.createStack,
addOutput: backend.addOutput,
stack: backend.rootStack,
};
};