Skip to content

Commit

Permalink
Merge branch 'master' into amplify-geo-headless
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronZyLee committed Oct 12, 2021
2 parents b244723 + e190292 commit d403cc0
Show file tree
Hide file tree
Showing 168 changed files with 9,048 additions and 714 deletions.
165 changes: 106 additions & 59 deletions .circleci/config.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = {
'<rootDir>/packages/amplify-graphql-function-transformer',
'<rootDir>/packages/amplify-graphql-http-transformer',
'<rootDir>/packages/amplify-graphql-index-transformer',
'<rootDir>/packages/amplify-graphql-default-value-transformer',
'<rootDir>/packages/amplify-graphql-model-transformer',
'<rootDir>/packages/amplify-graphql-predictions-transformer',
'<rootDir>/packages/amplify-graphql-relational-transformer',
Expand Down
8 changes: 8 additions & 0 deletions packages/amplify-app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [3.0.15](https://github.com/aws-amplify/amplify-cli/compare/amplify-app@3.0.14...amplify-app@3.0.15) (2021-10-10)

**Note:** Version bump only for package amplify-app





## [3.0.14](https://github.com/aws-amplify/amplify-cli/compare/amplify-app@3.0.13...amplify-app@3.0.14) (2021-10-06)

**Note:** Version bump only for package amplify-app
Expand Down
6 changes: 3 additions & 3 deletions packages/amplify-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-app",
"version": "3.0.14",
"version": "3.0.15",
"description": "Amplify CLI",
"repository": {
"type": "git",
Expand Down Expand Up @@ -30,8 +30,8 @@
"dependencies": {
"amplify-frontend-android": "2.15.4",
"amplify-frontend-flutter": "0.4.4",
"amplify-frontend-ios": "2.20.16",
"amplify-frontend-javascript": "2.24.3",
"amplify-frontend-ios": "2.20.17",
"amplify-frontend-javascript": "2.24.4",
"chalk": "^4.1.1",
"execa": "^5.1.1",
"fs-extra": "^8.1.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/amplify-category-analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.21.24](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-analytics@2.21.23...amplify-category-analytics@2.21.24) (2021-10-10)

**Note:** Version bump only for package amplify-category-analytics





## [2.21.23](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-analytics@2.21.22...amplify-category-analytics@2.21.23) (2021-10-06)

**Note:** Version bump only for package amplify-category-analytics
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-category-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-category-analytics",
"version": "2.21.23",
"version": "2.21.24",
"description": "amplify-cli analytics plugin",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,7 @@
"aws"
],
"dependencies": {
"amplify-cli-core": "1.31.0",
"amplify-cli-core": "1.31.1",
"fs-extra": "^8.1.0",
"inquirer": "^7.3.3",
"uuid": "^3.4.0"
Expand Down
11 changes: 11 additions & 0 deletions packages/amplify-category-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.33.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-api@2.33.0...amplify-category-api@2.33.1) (2021-10-10)


### Bug Fixes

* **amplify-category-api:** fixed api to reference stack name and deployment bucket ([#8145](https://github.com/aws-amplify/amplify-cli/issues/8145)) ([4c7493a](https://github.com/aws-amplify/amplify-cli/commit/4c7493ac34fa89cab0c80e5c674bbeb102891a64))





# [2.33.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-api@2.32.0...amplify-category-api@2.33.0) (2021-10-06)


Expand Down
6 changes: 3 additions & 3 deletions packages/amplify-category-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-category-api",
"version": "2.33.0",
"version": "2.33.1",
"description": "amplify-cli api plugin",
"repository": {
"type": "git",
Expand Down Expand Up @@ -63,15 +63,15 @@
"@aws-cdk/region-info": "~1.124.0",
"@graphql-tools/merge": "^6.0.18",
"@octokit/rest": "^18.0.9",
"amplify-cli-core": "1.31.0",
"amplify-cli-core": "1.31.1",
"amplify-headless-interface": "1.10.0",
"amplify-util-headless-input": "1.5.4",
"chalk": "^4.1.1",
"constructs": "^3.3.125",
"fs-extra": "^8.1.0",
"graphql": "^14.5.8",
"graphql-relational-schema-transformer": "2.18.7",
"graphql-transformer-core": "6.30.1",
"graphql-transformer-core": "6.30.2",
"inquirer": "^7.3.3",
"js-yaml": "^4.0.0",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as ec2 from '@aws-cdk/aws-ec2';
import * as ecr from '@aws-cdk/aws-ecr';
import * as ecs from '@aws-cdk/aws-ecs';
import * as iam from '@aws-cdk/aws-iam';
import { CfnFunction } from '@aws-cdk/aws-lambda';
import * as logs from '@aws-cdk/aws-logs';
import * as s3 from '@aws-cdk/aws-s3';
import * as ssm from '@aws-cdk/aws-secretsmanager';
Expand Down Expand Up @@ -31,10 +32,8 @@ export enum DEPLOYMENT_MECHANISM {

export type ContainersStackProps = Readonly<{
skipWait?: boolean;
envName: string;
categoryName: string;
apiName: string;
deploymentBucketName: string;
dependsOn: ReadonlyArray<{
category: string;
resourceName: string;
Expand All @@ -53,6 +52,7 @@ export type ContainersStackProps = Readonly<{
createCloudMapService?: boolean;
gitHubSourceActionInfo?: GitHubSourceActionInfo;
existingEcrRepositories: Set<string>;
currentStackName: string;
}>;
export abstract class ContainersStack extends cdk.Stack {
protected readonly vpcId: string;
Expand All @@ -70,6 +70,9 @@ export abstract class ContainersStack extends cdk.Stack {
protected readonly userPoolId: string | undefined;
protected readonly ecsServiceSecurityGroup: ec2.CfnSecurityGroup;
protected readonly parameters: ReadonlyMap<string, cdk.CfnParameter>;
protected readonly envName: string;
protected readonly deploymentBucketName: string;
protected readonly awaiterS3Key: string;

constructor(scope: cdk.Construct, id: string, private readonly props: ContainersStackProps) {
super(scope, id);
Expand All @@ -86,6 +89,9 @@ export abstract class ContainersStack extends cdk.Stack {
isAuthCondition,
appClientId,
userPoolId,
envName,
deploymentBucketName,
awaiterS3Key,
} = this.init();

this.parameters = parameters;
Expand All @@ -100,7 +106,9 @@ export abstract class ContainersStack extends cdk.Stack {
this.isAuthCondition = isAuthCondition;
this.appClientId = appClientId;
this.userPoolId = userPoolId;

this.envName = envName;
this.deploymentBucketName = deploymentBucketName;
this.awaiterS3Key = awaiterS3Key;
const { service, serviceSecurityGroup, containersInfo, cloudMapService } = this.ecs();

this.cloudMapService = cloudMapService;
Expand Down Expand Up @@ -192,6 +200,17 @@ export abstract class ContainersStack extends cdk.Stack {
),
});

const stackNameParameter = new cdk.CfnParameter(this, 'rootStackName', {
type: 'String',
});

const deploymentBucketName = new cdk.CfnParameter(this, 'deploymentBucketName', {
type: 'String',
});
const awaiterS3Key = new cdk.CfnParameter(this, 'awaiterS3Key', {
type: 'String',
default: PIPELINE_AWAITER_ZIP,
});
return {
parameters,
vpcId: paramVpcId.valueAsString,
Expand All @@ -204,12 +223,14 @@ export abstract class ContainersStack extends cdk.Stack {
isAuthCondition,
userPoolId: paramUserPoolId && paramUserPoolId.valueAsString,
appClientId: paramAppClientIdWeb && paramAppClientIdWeb.valueAsString,
envName: stackNameParameter.valueAsString,
deploymentBucketName: deploymentBucketName.valueAsString,
awaiterS3Key: awaiterS3Key.valueAsString,
};
}

private ecs() {
const {
envName,
categoryName,
apiName,
policies,
Expand All @@ -220,6 +241,7 @@ export abstract class ContainersStack extends cdk.Stack {
taskPorts,
isInitialDeploy,
desiredCount,
currentStackName,
createCloudMapService,
} = this.props;

Expand All @@ -245,7 +267,7 @@ export abstract class ContainersStack extends cdk.Stack {
compatibility: ecs.Compatibility.FARGATE,
memoryMiB: '1024',
cpu: '512',
family: `${envName}-${apiName}`,
family: `${this.envName}-${apiName}`,
});
(task.node.defaultChild as ecs.CfnTaskDefinition).overrideLogicalId('TaskDefinition');
policies.forEach(policy => {
Expand Down Expand Up @@ -274,7 +296,7 @@ export abstract class ContainersStack extends cdk.Stack {
secrets: containerSecrets,
}) => {
const logGroup = new logs.LogGroup(this, `${name}ContainerLogGroup`, {
logGroupName: `/ecs/${envName}-${apiName}-${name}`,
logGroupName: `/ecs/${this.envName}-${apiName}-${name}`,
retention: logs.RetentionDays.ONE_MONTH,
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
Expand All @@ -293,13 +315,13 @@ export abstract class ContainersStack extends cdk.Stack {
if (build) {
const logicalId = `${name}Repository`;

const repositoryName = `${envName}-${categoryName}-${apiName}-${name}`;
const repositoryName = `${currentStackName}-${categoryName}-${apiName}-${name}`;

if (this.props.existingEcrRepositories.has(repositoryName)) {
repository = ecr.Repository.fromRepositoryName(this, logicalId, repositoryName);
} else {
repository = new ecr.Repository(this, logicalId, {
repositoryName: `${envName}-${categoryName}-${apiName}-${name}`,
repositoryName: `${this.envName}-${categoryName}-${apiName}-${name}`,
removalPolicy: cdk.RemovalPolicy.RETAIN,
lifecycleRules: [
{
Expand Down Expand Up @@ -446,15 +468,15 @@ export abstract class ContainersStack extends cdk.Stack {
}[];
gitHubSourceActionInfo?: GitHubSourceActionInfo;
}) {
const { envName, deploymentBucketName, deploymentMechanism, desiredCount } = this.props;
const { deploymentMechanism, desiredCount } = this.props;

const s3SourceActionKey = this.zipPath;

const bucket = s3.Bucket.fromBucketName(this, 'Bucket', deploymentBucketName);
const bucket = s3.Bucket.fromBucketName(this, 'Bucket', this.deploymentBucketName);

const pipelineWithAwaiter = new PipelineWithAwaiter(this, 'ApiPipeline', {
skipWait,
envName,
envName: this.envName,
containersInfo,
service,
bucket,
Expand All @@ -477,26 +499,29 @@ export abstract class ContainersStack extends cdk.Stack {
const pipelineName = this.getPipelineName();
return `https://${region}.console.aws.amazon.com/codesuite/codepipeline/pipelines/${pipelineName}/view`;
}

toCloudFormation() {
this.node
.findAll()
.filter(construct => construct instanceof CfnFunction)
.map(construct => construct as CfnFunction)
.forEach(lambdaFunction => {
if (lambdaFunction.logicalId.includes('AwaiterMyProvider')) {
lambdaFunction.code = {
s3Bucket: this.deploymentBucketName,
s3Key: this.awaiterS3Key,
};
}
});

prepareApp(this);

const cfn = this._toCloudFormation();

Object.keys(cfn.Parameters).forEach(k => {
if (k.startsWith('AssetParameters')) {
let value = '';

if (k.includes('Bucket')) {
value = this.props.deploymentBucketName;
} else if (k.includes('VersionKey')) {
value = `${PIPELINE_AWAITER_ZIP}||`;
}

cfn.Parameters[k].Default = value;
delete cfn.Parameters[k];
}
});

return cfn;
}
}
Expand Down

0 comments on commit d403cc0

Please sign in to comment.