Skip to content

Commit 1961050

Browse files
author
Dillon Nys
committed
Merge remote-tracking branch 'aws/next' into feat/aft/changlog
2 parents 7f71862 + 3a9a818 commit 1961050

File tree

2,324 files changed

+23093
-12154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,324 files changed

+23093
-12154
lines changed

.github/composite_actions/setup_firefox/action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ description: Install Firefox and Geckodriver
44
runs:
55
using: "composite"
66
steps:
7-
- uses: browser-actions/setup-firefox@c990ef23a9bedbbe657b163aaf0f3b7c608ea9f0 # latest
7+
- uses: browser-actions/setup-firefox@c990ef23a9bedbbe657b163aaf0f3b7c608ea9f0 # master
88
- shell: bash
99
run: firefox --version
10-
- uses: browser-actions/setup-geckodriver@1605d95d4e5e7f5e3706e1e6f9c839d3834159db # latest
10+
- uses: browser-actions/setup-geckodriver@1605d95d4e5e7f5e3706e1e6f9c839d3834159db # master
1111
- shell: bash
1212
run: geckodriver --version
1313
- name: Virtual X Display

.github/dependabot.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ updates:
3232
schedule:
3333
interval: "daily"
3434
- package-ecosystem: "pub"
35-
directory: "packages/amplify_authenticator/"
35+
directory: "packages/authenticator/amplify_authenticator/"
3636
schedule:
3737
interval: "daily"
3838
- package-ecosystem: "pub"
39-
directory: "packages/amplify_authenticator/example/"
39+
directory: "packages/authenticator/amplify_authenticator/example/"
4040
schedule:
4141
interval: "daily"
4242
- package-ecosystem: "pub"
43-
directory: "packages/amplify_authenticator/example/.dart_tool/flutter_gen/"
43+
directory: "packages/authenticator/amplify_authenticator/example/.dart_tool/flutter_gen/"
4444
schedule:
4545
interval: "daily"
4646
- package-ecosystem: "pub"

.github/workflows/amplify_authenticator.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ on:
88
- next
99
pull_request:
1010
paths:
11-
- 'packages/amplify_authenticator/**/*.dart'
12-
- 'packages/amplify_authenticator/**/*.yaml'
13-
- 'packages/amplify_authenticator/lib/**/*'
14-
- 'packages/amplify_authenticator/test/**/*'
11+
- 'packages/authenticator/amplify_authenticator/**/*.dart'
12+
- 'packages/authenticator/amplify_authenticator/**/*.yaml'
13+
- 'packages/authenticator/amplify_authenticator/lib/**/*'
14+
- 'packages/authenticator/amplify_authenticator/test/**/*'
1515
- '.github/workflows/flutter_vm.yaml'
1616
- '.github/workflows/amplify_authenticator.yaml'
1717
schedule:
18-
- cron: "0 0 * * 0" # Every Sunday at 00:00
18+
- cron: '0 0 * * 0' # Every Sunday at 00:00
1919
defaults:
2020
run:
2121
shell: bash
@@ -25,4 +25,4 @@ jobs:
2525
test:
2626
uses: ./.github/workflows/flutter_vm.yaml
2727
with:
28-
working-directory: packages/amplify_authenticator
28+
working-directory: packages/authenticator/amplify_authenticator

infra/lib/auth/stack.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import * as iam from "aws-cdk-lib/aws-iam";
2323
import * as kms from "aws-cdk-lib/aws-kms";
2424
import * as lambda from "aws-cdk-lib/aws-lambda";
2525
import * as lambda_nodejs from "aws-cdk-lib/aws-lambda-nodejs";
26-
import * as wafv2 from "aws-cdk-lib/aws-wafv2";
2726
import { Construct } from "constructs";
2827
import * as path from "path";
2928
import {
@@ -47,9 +46,9 @@ export type AuthIntegrationTestStackEnvironmentProps =
4746
export interface AuthBaseEnvironmentProps
4847
extends IntegrationTestStackEnvironmentProps {
4948
/**
50-
* The shared WAF.
49+
* Associates `resourceArn` with the shared WAF.
5150
*/
52-
waf: wafv2.CfnWebACL;
51+
associateWithWaf: (resourceArn: string) => void;
5352

5453
/**
5554
* The type of environment to build.
@@ -135,7 +134,7 @@ class AuthIntegrationTestStackEnvironment extends IntegrationTestStackEnvironmen
135134
) {
136135
super(scope, baseName, props);
137136

138-
const { waf } = props;
137+
const { associateWithWaf } = props;
139138

140139
// Create the GraphQL API for admin actions
141140

@@ -325,15 +324,8 @@ class AuthIntegrationTestStackEnvironment extends IntegrationTestStackEnvironmen
325324
}
326325
);
327326

328-
new wafv2.CfnWebACLAssociation(this, "WAFAppSyncAssociation", {
329-
resourceArn: graphQLApi.arn,
330-
webAclArn: waf.attrArn,
331-
});
332-
333-
new wafv2.CfnWebACLAssociation(this, "WAFCognitoAssociation", {
334-
resourceArn: userPool.userPoolArn,
335-
webAclArn: waf.attrArn,
336-
});
327+
associateWithWaf(graphQLApi.arn);
328+
associateWithWaf(userPool.userPoolArn);
337329

338330
// Create the DynamoDB table to store MFA codes for AppSync subscriptions
339331

infra/lib/stack.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,23 @@ export class AmplifyFlutterIntegStack extends cdk.Stack {
7171
},
7272
});
7373

74+
const wafAssociations: wafv2.CfnWebACLAssociation[] = [];
75+
76+
// Creates a WAF association on `this` so that they can be chained later
77+
// and do not block the concurrent creation of environments.
78+
const associateWithWaf = (resourceArn: string) => {
79+
wafAssociations.push(
80+
new wafv2.CfnWebACLAssociation(
81+
this,
82+
`WAFAssociation${wafAssociations.length}`,
83+
{
84+
resourceArn,
85+
webAclArn: waf.attrArn,
86+
}
87+
)
88+
);
89+
};
90+
7491
// The Analytics stack
7592
const analytics = new AnalyticsIntegrationTestStack(this, [
7693
{ environmentName: "main" },
@@ -81,16 +98,16 @@ export class AmplifyFlutterIntegStack extends cdk.Stack {
8198
const customDomain = this.node.tryGetContext("domainName");
8299
if (customDomain) {
83100
customDomainEnv.push({
84-
waf,
101+
associateWithWaf,
85102
type: "CUSTOM_AUTHORIZER_IAM",
86103
environmentName: "custom-authorizer-custom-domain",
87104
customDomain,
88105
});
89106
}
90107
const auth = new AuthIntegrationTestStack(this, [
91-
{ waf, type: "FULL", environmentName: "main" },
108+
{ associateWithWaf, type: "FULL", environmentName: "main" },
92109
{
93-
waf,
110+
associateWithWaf,
94111
type: "FULL",
95112
environmentName: "device-tracking-always",
96113
deviceTracking: {
@@ -101,7 +118,7 @@ export class AmplifyFlutterIntegStack extends cdk.Stack {
101118
},
102119
},
103120
{
104-
waf,
121+
associateWithWaf,
105122
type: "FULL",
106123
environmentName: "device-tracking-opt-in",
107124
deviceTracking: {
@@ -112,20 +129,20 @@ export class AmplifyFlutterIntegStack extends cdk.Stack {
112129
},
113130
},
114131
{
115-
waf,
132+
associateWithWaf,
116133
type: "FULL",
117134
environmentName: "sign-in-with-phone",
118135
signInAliases: {
119136
phone: true,
120137
},
121138
},
122139
{
123-
waf,
140+
associateWithWaf,
124141
type: "CUSTOM_AUTHORIZER_USER_POOLS",
125142
environmentName: "custom-authorizer-user-pools",
126143
},
127144
{
128-
waf,
145+
associateWithWaf,
129146
type: "CUSTOM_AUTHORIZER_IAM",
130147
environmentName: "custom-authorizer-iam",
131148
},
@@ -158,6 +175,13 @@ export class AmplifyFlutterIntegStack extends cdk.Stack {
158175
this.outputAmplifyConfig(analytics);
159176
this.outputAmplifyConfig(auth);
160177
this.outputAmplifyConfig(storage);
178+
179+
// Chain the creation of WAF associations since the API call `AssociateWebACL`
180+
// has a fixed rate limit which can easily be exceeded when deploying concurrent
181+
// stacks and their WAF associations.
182+
wafAssociations.forEach((assoc, index) => {
183+
if (index > 0) assoc.addDependsOn(wafAssociations[index - 1]);
184+
});
161185
}
162186

163187
/**

packages/aft/lib/src/commands/generate/generate_sdk_command.dart

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
import 'dart:async';
16+
import 'dart:convert';
1617
import 'dart:io';
1718

1819
import 'package:aft/aft.dart';
@@ -78,10 +79,17 @@ class GenerateSdkCommand extends AmplifyCommand {
7879
['checkout', ref],
7980
processWorkingDir: cloneDir.path,
8081
);
81-
logger.verbose('Successfully cloned models');
82+
logger.info('Successfully cloned models');
83+
return cloneDir;
84+
}
85+
86+
/// Organizes model files from [baseDir] into a new temporary directory.
87+
///
88+
/// Returns the new directory.
89+
Future<Directory> _organizeModels(Directory baseDir) async {
8290
final modelsDir = await Directory.systemTemp.createTemp('models');
83-
logger.verbose('Organizing models in ${modelsDir.path}');
84-
final services = cloneDir.list(followLinks: false).whereType<Directory>();
91+
logger.debug('Organizing models in ${modelsDir.path}');
92+
final services = baseDir.list(followLinks: false).whereType<Directory>();
8593
await for (final serviceDir in services) {
8694
final serviceName = p.basename(serviceDir.path);
8795
final artifacts = await serviceDir.list().whereType<Directory>().toList();
@@ -116,12 +124,13 @@ class GenerateSdkCommand extends AmplifyCommand {
116124
final modelsPath = args['models'] as String?;
117125
final Directory modelsDir;
118126
if (modelsPath != null) {
119-
modelsDir = Directory(modelsPath);
127+
modelsDir = await _organizeModels(Directory(modelsPath));
120128
if (!await modelsDir.exists()) {
121129
exitError('Model directory ($modelsDir) does not exist');
122130
}
123131
} else {
124-
modelsDir = await _downloadModels(config.ref);
132+
final cloneDir = await _downloadModels(config.ref);
133+
modelsDir = await _organizeModels(cloneDir);
125134
}
126135

127136
final outputPath = args['output'] as String;
@@ -174,15 +183,15 @@ class GenerateSdkCommand extends AmplifyCommand {
174183
}
175184

176185
// Generate SDK for combined operations
177-
final libraries = generateForAst(
186+
final output = generateForAst(
178187
smithyAst,
179188
packageName: packageName,
180189
basePath: outputPath,
181190
includeShapes: includeShapes,
182191
);
183192

184193
final dependencies = <String>{};
185-
for (final library in libraries) {
194+
for (final library in output.values.expand((out) => out.libraries)) {
186195
final smithyLibrary = library.smithyLibrary;
187196
final outPath = p.join(
188197
'lib',
@@ -195,6 +204,33 @@ class GenerateSdkCommand extends AmplifyCommand {
195204
await outFile.writeAsString(output);
196205
}
197206

207+
for (final plugin in config.plugins) {
208+
logger.info('Running plugin $plugin...');
209+
final generatedShapes = ShapeMap(
210+
Map.fromEntries(
211+
output.values.expand((out) => out.context.shapes.entries),
212+
),
213+
);
214+
final generatedAst = SmithyAst(
215+
(b) => b
216+
..shapes = generatedShapes
217+
..metadata.replace(smithyAst.metadata)
218+
..version = smithyAst.version,
219+
);
220+
final pluginCmd = await Process.start(
221+
'dart',
222+
[
223+
plugin,
224+
jsonEncode(generatedAst),
225+
],
226+
mode: verbose ? ProcessStartMode.inheritStdio : ProcessStartMode.normal,
227+
);
228+
final exitCode = await pluginCmd.exitCode;
229+
if (exitCode != 0) {
230+
exitError('`dart $plugin <AST>` failed: $exitCode.');
231+
}
232+
}
233+
198234
// Run built_value generator
199235
final buildRunnerCmd = await Process.start(
200236
'dart',
@@ -204,11 +240,8 @@ class GenerateSdkCommand extends AmplifyCommand {
204240
'build',
205241
'--delete-conflicting-outputs',
206242
],
243+
mode: verbose ? ProcessStartMode.inheritStdio : ProcessStartMode.normal,
207244
);
208-
if (verbose) {
209-
unawaited(buildRunnerCmd.stdout.pipe(stdout));
210-
unawaited(buildRunnerCmd.stderr.pipe(stderr));
211-
}
212245
final exitCode = await buildRunnerCmd.exitCode;
213246
if (exitCode != 0) {
214247
exitError('`dart run build_runner build` failed: $exitCode.');

packages/aft/lib/src/models.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ class SdkConfig
482482
const SdkConfig({
483483
this.ref = 'master',
484484
required this.apis,
485+
this.plugins = const [],
485486
});
486487

487488
factory SdkConfig.fromJson(Map<Object?, Object?>? json) =>
@@ -492,12 +493,13 @@ class SdkConfig
492493
/// Defaults to `master`.
493494
final String ref;
494495
final Map<String, List<ShapeId>?> apis;
496+
final List<String> plugins;
495497

496498
@override
497499
Map<String, Object?> toJson() => _$SdkConfigToJson(this);
498500

499501
@override
500-
List<Object?> get props => [apis];
502+
List<Object?> get props => [ref, apis, plugins];
501503

502504
@override
503505
String get runtimeTypeName => 'SdkConfig';

packages/aft/lib/src/models.g.dart

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/amplify/amplify_flutter/lib/src/hybrid_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class AmplifyHybridImpl extends AmplifyClassImpl {
9494
} else if (plugin is APIPluginInterface) {
9595
await API.addPlugin(plugin, authProviderRepo: authProviderRepo);
9696
} else {
97-
throw AmplifyException(
97+
throw PluginError(
9898
'The type of plugin ${plugin.runtimeType} is not yet supported '
9999
'in Amplify.',
100100
recoverySuggestion:
@@ -105,7 +105,7 @@ class AmplifyHybridImpl extends AmplifyClassImpl {
105105
return;
106106
} on Exception catch (e) {
107107
safePrint('Amplify plugin was not added');
108-
throw AmplifyException(
108+
throw PluginError(
109109
'Amplify plugin ${plugin.runtimeType} was not added successfully.',
110110
recoverySuggestion: AmplifyExceptionMessages.missingRecoverySuggestion,
111111
underlyingException: e,

0 commit comments

Comments
 (0)