aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
184 stars 62 forks source link

[POC] Introduce and enforce new stack structure #2158

Open rtpascual opened 2 weeks ago

rtpascual commented 2 weeks ago

Problem

Issue number, if available:

Changes

Introduces defineStack for passing backend resources into (auth, data, etc.) and update DefineBackendProps to only take in backend stacks from defineStack. These changes would be part of the next major version, intermediate changes are in https://github.com/aws-amplify/amplify-backend/pull/2157.

The code using this solution looks like this:

import { defineAuth, defineData, defineFunction, defineStack } from '@aws-amplify/backend';

// define resources
const auth = defineAuth({ ... });
const data = defineData({ ... });
const function = defineFunction({ ... });

export const stack1 = defineStack('stack1', { auth, data, function });
// amplify/backend.ts
import { defineBackend } from '@aws-amplify/backend';

const backend = defineBackend({ stack1 });

// examples of accessing resources
backend.stack1.resources.stack
backend.stack1.resources.auth.resources.userPool
backend.stack1.resources.function.resources.cfnResources.cfnFunction
backend.stack1.resources.function.addEnvironment(...)

Corresponding docs PR, if applicable:

Validation

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

changeset-bot[bot] commented 2 weeks ago

⚠️ No Changeset found

Latest commit: 5b136f6cb9e528a49a5da9ef57440f0ddfb1f42e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR