Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental stackmapping changes for Gen2 #1593

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/mean-toys-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/backend-data': minor
---

Added experimental option to map data resources to nested stacks
2 changes: 2 additions & 0 deletions .changeset/spicy-rules-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
12 changes: 9 additions & 3 deletions .github/workflows/health_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ jobs:
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/restore_install_cache
- run: git fetch origin
- run: npm run diff:check ${{ github.event.pull_request.base.sha }}
- run: npm run diff:check "$BASE_SHA"
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
check_pr_changesets:
if: github.event_name == 'pull_request' && github.event.pull_request.user.login != 'github-actions[bot]'
runs-on: ubuntu-latest
Expand All @@ -406,9 +408,13 @@ jobs:
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/restore_install_cache
- name: Validate that PR has changeset
run: npx changeset status --since origin/${{ github.event.pull_request.base.ref }}
run: npx changeset status --since origin/"$BASE_REF"
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
- name: Validate changeset is not missing packages
run: npx tsx scripts/check_changeset_completeness.ts ${{ github.event.pull_request.base.sha }}
run: npx tsx scripts/check_changeset_completeness.ts "$BASE_SHA"
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
- name: Validate that changeset has necessary dependency updates
run: |
npx changeset version
Expand Down
1 change: 1 addition & 0 deletions packages/backend-data/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type DataProps = {
name?: string;
authorizationModes?: AuthorizationModes;
functions?: Record<string, ConstructFactory<AmplifyFunction>>;
experimentalStackMapping?: Record<string, string>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's review the API design internally. We may need a consolidated attribute to configure experimental features.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just works like gen1. It was working property on Gen 1. Now it can be usable on Gen 2. I don't know if it's experimental or not for this reason but it's works on Cloudformation same as gen 1.

But changing stacks with gen 1 or gen 2 not effecting resource limit on Cloudformation. These are still hits the resource limit

};

// @public
Expand Down
1 change: 1 addition & 0 deletions packages/backend-data/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class DataGenerator implements ConstructContainerEntryGenerator {
authorizationModes,
outputStorageStrategy: this.outputStorageStrategy,
functionNameMap,
stackMappings: this.props.experimentalStackMapping,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this experimental if it's mapping to construct property that is not experimental in underlying construct ?

translationBehavior: {
sandboxModeEnabled,
/**
Expand Down
6 changes: 6 additions & 0 deletions packages/backend-data/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export type DataProps = {
* Functions invokable by the API. The specific input type of the function is subject to change or removal.
*/
functions?: Record<string, ConstructFactory<AmplifyFunction>>;

/**
* ExperimentalStackMapping override the assigned nested stack on a per-resource basis. Only applies to resolvers, and takes the form
* { <logicalId>: <stackName> }
*/
experimentalStackMapping?: Record<string, string>;
Comment on lines +143 to +147
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have not yet finalized a method to expose experimental APIs so please hold with this change.

};

export type AmplifyDataError =
Expand Down
9 changes: 6 additions & 3 deletions scripts/publish_runner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Options, execa } from 'execa';
import { runVersion } from './version_runner.js';
import { NpmClient } from './components/npm_client.js';
import fs from 'fs';
import path from 'path';

export type PublishOptions = {
/**
Expand Down Expand Up @@ -52,9 +54,10 @@ export const runPublish = async (props?: PublishOptions, cwd?: string) => {
}

if (options.snapshotRelease) {
// Snapshot releases are not allowed in pre mode.
// Exit pre mode. This is no-op if not in pre mode.
await execa('changeset', ['pre', 'exit'], execaOptions);
if (fs.existsSync(path.join('.changeset', 'pre.json'))) {
// Snapshot releases are not allowed in pre mode.
await execa('changeset', ['pre', 'exit'], execaOptions);
}
await runVersion(['--snapshot', snapshotTag], cwd);
}

Expand Down
Loading