Skip to content

Commit

Permalink
refactor(ci): Allow region split (#3708)
Browse files Browse the repository at this point in the history
* refactor(ci): Allow region split

* ci(auth): Use `eu-south-1`

For testing eventual consistency issues.

* trigger ci

* test

* test

* revert eu-south-1

* Remove test
  • Loading branch information
dnys1 authored and Equartey committed Oct 30, 2023
1 parent 455fcf1 commit cfb565d
Show file tree
Hide file tree
Showing 15 changed files with 2,036 additions and 1,241 deletions.
5 changes: 1 addition & 4 deletions infra/bin/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

import * as cdk from "aws-cdk-lib";
import "source-map-support/register";
import { env } from "../lib/common";
import { AmplifyFlutterIntegStack } from "../lib/stack";

const app = new cdk.App();
const env: cdk.Environment = {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
};

new AmplifyFlutterIntegStack(app, "AmplifyFlutterIntegStack", {
env,
Expand Down
19 changes: 11 additions & 8 deletions infra/lib/analytics/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
AmplifyCategory,
IntegrationTestStack,
IntegrationTestStackEnvironment,
IntegrationTestStackEnvironmentProps
IntegrationTestStackEnvironmentProps,
inOneYear
} from "../common";

export interface AnalyticsIntegrationTestStackEnvironmentProps extends IntegrationTestStackEnvironmentProps {
Expand All @@ -44,7 +45,7 @@ export class AnalyticsIntegrationTestStack extends IntegrationTestStack<
constructor(
scope: Construct,
environments: AnalyticsIntegrationTestStackEnvironmentProps[],
props?: cdk.NestedStackProps
props?: cdk.StackProps
) {
super({
scope,
Expand Down Expand Up @@ -164,14 +165,16 @@ class AnalyticsIntegrationTestStackEnvironment extends IntegrationTestStackEnvir
const authorizationType = appsync.AuthorizationType.API_KEY;
const graphQLApi = new appsync.GraphqlApi(this, "GraphQLApi", {
name: this.name,
schema: appsync.SchemaFile.fromAsset(
path.resolve(__dirname, "schema.graphql")
),
definition: {
schema: appsync.SchemaFile.fromAsset(
path.resolve(__dirname, "schema.graphql")
),
},
authorizationConfig: {
defaultAuthorization: {
authorizationType,
apiKeyConfig: {
expires: Expiration.after(Duration.days(365)),
expires: inOneYear(),
},
},
},
Expand Down Expand Up @@ -237,7 +240,7 @@ class AnalyticsIntegrationTestStackEnvironment extends IntegrationTestStackEnvir

// Output the values needed to build our Amplify configuration.

this.config = {
this.saveConfig({
analyticsConfig: {
appId: pinpointApp.ref,
},
Expand All @@ -256,6 +259,6 @@ class AnalyticsIntegrationTestStackEnvironment extends IntegrationTestStackEnvir
identityPoolId: identityPool.identityPoolId,
},
},
};
});
}
}
6 changes: 3 additions & 3 deletions infra/lib/auth/custom-authorizer-iam/stack.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import * as cognito_identity from "@aws-cdk/aws-cognito-identitypool-alpha";
import * as apigw from "aws-cdk-lib/aws-apigateway";
import * as acm from "aws-cdk-lib/aws-certificatemanager";
import * as cognito_identity from "@aws-cdk/aws-cognito-identitypool-alpha";
import * as iam from "aws-cdk-lib/aws-iam";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as lambda_nodejs from "aws-cdk-lib/aws-lambda-nodejs";
Expand Down Expand Up @@ -134,7 +134,7 @@ export class CustomAuthorizerIamStackEnvironment extends IntegrationTestStackEnv
domainName = `https://${apiGateway.domainName?.domainName}/prod/`;
}

this.config = {
this.saveConfig({
apiConfig: {
apis: {
[apiGateway.restApiName]: {
Expand All @@ -149,6 +149,6 @@ export class CustomAuthorizerIamStackEnvironment extends IntegrationTestStackEnv
identityPoolId: identityPool.identityPoolId,
},
},
};
});
}
}
4 changes: 2 additions & 2 deletions infra/lib/auth/custom-authorizer-user-pools/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class CustomAuthorizerUserPoolsStackEnvironment extends IntegrationTestSt
},
});

this.config = {
this.saveConfig({
apiConfig: {
apis: {
[apiGateway.restApiName]: {
Expand All @@ -107,6 +107,6 @@ export class CustomAuthorizerUserPoolsStackEnvironment extends IntegrationTestSt
mfa,
},
},
};
});
}
}
35 changes: 16 additions & 19 deletions infra/lib/auth/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
IntegrationTestStackEnvironment,
IntegrationTestStackEnvironmentProps,
Mutable,
UserPoolConfig
UserPoolConfig,
inOneYear
} from "../common";
import { UserMfaPreference } from "./common";
import { CustomAuthorizerIamStackEnvironment } from "./custom-authorizer-iam/stack";
Expand All @@ -38,11 +39,6 @@ export type AuthIntegrationTestStackEnvironmentProps =

export interface AuthBaseEnvironmentProps
extends IntegrationTestStackEnvironmentProps {
/**
* Associates `resourceArn` with the shared WAF.
*/
associateWithWaf: (name: string, resourceArn: string) => void;

/**
* The type of environment to build.
*/
Expand Down Expand Up @@ -159,24 +155,24 @@ export interface AuthCustomAuthorizerEnvironmentProps {

export class AuthIntegrationTestStack extends IntegrationTestStack<
AuthIntegrationTestStackEnvironmentProps,
AuthIntegrationTestStackEnvironment
IntegrationTestStackEnvironment<AuthIntegrationTestStackEnvironmentProps>
> {
constructor(
scope: Construct,
environments: AuthIntegrationTestStackEnvironmentProps[],
props?: cdk.NestedStackProps
props?: cdk.StackProps
) {
super({
scope,
category: AmplifyCategory.Auth,
environments,
environments: environments,
props,
});
}

protected buildEnvironments(
props: AuthIntegrationTestStackEnvironmentProps[]
): AuthIntegrationTestStackEnvironment[] {
) {
return props.map((environment) => {
switch (environment.type) {
case "FULL":
Expand Down Expand Up @@ -211,7 +207,6 @@ class AuthIntegrationTestStackEnvironment extends IntegrationTestStackEnvironmen
super(scope, baseName, props);

const {
associateWithWaf,
autoConfirm = false,
enableHostedUI = false,
signInAliases,
Expand Down Expand Up @@ -241,14 +236,16 @@ class AuthIntegrationTestStackEnvironment extends IntegrationTestStackEnvironmen
const authorizationType = appsync.AuthorizationType.API_KEY;
const graphQLApi = new appsync.GraphqlApi(this, "GraphQLApi", {
name: this.name,
schema: appsync.SchemaFile.fromAsset(
path.resolve(__dirname, "schema.graphql")
),
definition: {
schema: appsync.SchemaFile.fromAsset(
path.resolve(__dirname, "schema.graphql")
),
},
authorizationConfig: {
defaultAuthorization: {
authorizationType,
apiKeyConfig: {
expires: Expiration.after(Duration.days(365)),
expires: inOneYear(),
},
},
},
Expand Down Expand Up @@ -495,8 +492,8 @@ class AuthIntegrationTestStackEnvironment extends IntegrationTestStackEnvironmen
},
});

associateWithWaf(`${this.environmentName}GraphQL`, graphQLApi.arn);
associateWithWaf(`${this.environmentName}UserPool`, userPool.userPoolArn);
this.associateWithWaf(`${this.environmentName}GraphQL`, graphQLApi.arn);
this.associateWithWaf(`${this.environmentName}UserPool`, userPool.userPoolArn);

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

Expand Down Expand Up @@ -713,13 +710,13 @@ class AuthIntegrationTestStackEnvironment extends IntegrationTestStackEnvironmen
scopes: scopes.map((scope) => scope.scopeName),
};
}
this.config = {
this.saveConfig({
apiConfig,
authConfig: {
userPoolConfig,
identityPoolConfig,
hostedUiConfig,
},
};
});
}
}
Loading

0 comments on commit cfb565d

Please sign in to comment.