Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6a34681
codepipeline branch integration with codepipeline
amigitamz Nov 3, 2023
a54567c
add watchall flag for tests
amigitamz Nov 3, 2023
d245250
fix infra test
amigitamz Nov 3, 2023
d6303c4
add esbuild installation
amigitamz Nov 3, 2023
8a177cb
remove self mutation
amigitamz Nov 3, 2023
9c754e1
enable self mutation
amigitamz Nov 3, 2023
186795a
add synth for codepipeline
amigitamz Nov 3, 2023
9484b24
update install commands
amigitamz Nov 3, 2023
2d0d3fa
infra cdk build
amigitamz Nov 10, 2023
bab4b03
undo nag changes
amigitamz Nov 16, 2023
f908173
remove CDK Pipeline and move to CodePipeline
amigitamz Nov 16, 2023
effdb97
mitigate cfn nag errors
amigitamz Nov 16, 2023
235f068
add pipelineSynthesizer env variable
amigitamz Nov 18, 2023
3479979
add logging
amigitamz Nov 18, 2023
2b3b459
add install command and permissions for build role
amigitamz Nov 18, 2023
194ad16
update readme, add comments and arch diagram
amigitamz Nov 19, 2023
3ba566a
update readme, add comments and arch diagram
amigitamz Nov 19, 2023
0e9574f
fix readme formatting
amigitamz Nov 19, 2023
61dbdbb
fix readme formatting
amigitamz Nov 19, 2023
d5767cc
fix indentation for env variable commands
amigitamz Nov 19, 2023
a61e759
add empty test for codepipeline
amigitamz Nov 19, 2023
a0da19f
undo change with watchAll flag for tests
amigitamz Nov 19, 2023
039c39d
undo changes in infra package-lock.json
amigitamz Nov 19, 2023
3b0bd51
undo changes in infra
amigitamz Nov 19, 2023
97c3a13
run prettier
amigitamz Nov 19, 2023
c80bced
prettier format
amigitamz Nov 20, 2023
606e9f3
add amazon copyright header and enable eslint check for codepipeline
amigitamz Nov 20, 2023
a6cdca2
undo changes to infra tests
amigitamz Nov 20, 2023
e1942a2
run prettier on codepipeline
amigitamz Nov 20, 2023
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
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,51 @@ Please take note:

### Deploy VAMS for the First Time

#### Build & Deploy Steps (Linux/Mac)
VAMS can be deployed from your local machine directly or by deploying a CI/CD pipeline connected to your VAMS repository and performing continous deployments using the CI/CD pipeline.

#### Deploying using CodePipeline

##### Create a CodeStar Connection

Connections are configurations that you use to connect AWS resources to external code repositories. VAMS solution uses [AWS CodePipeline](https://aws.amazon.com/codepipeline/) to deploy the resources and this connection will provide CodePipeline access to source code as well as trigger the pipeline everytime there is a code change in your repository.

1. Create a fork of this repository in your Github account.

2. Follow the steps provided [here](https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-github.html) to create a connection between the forked repository in your account and your AWS account using CodePipeline console.

3. Once you have successfully created the connection, note down the ARN for the connection. This ARN will be used in later steps.

##### Build and deploy VAMS using CI/CD pipeline

In order to deploy VAMS using CI/CD pipeline, you need to perform a one time deployment of the CodePipeline stack. Consequent updates to VAMS can be pushed to your forked code repository and this will trigger a new build and deployment in CodePipeline automatically.

Follow the below given steps to deploy the CI/CD pipeline -

1. `cd codepipeline` - The stack for deploying CodePipeline is in codepipeline folder.

2. If you haven't already bootstrapped your aws account with CDK. `cdk bootstrap aws://ACCOUNT_ID/REGION` - replace with your account and region.

3. Set the required environment variables. Replace with the region you would like to deploy to and the name you want to associate with the cloudformation stack that the CDK will deploy. Replace the Connection ARN with the ARN from previous step.You may also have to set DOCKER_DEFAULT_PLATFORM environment variable depending on the type of OS you are running this on. Default uses linux/amd64 -

```
export AWS_REGION=us-east-1
export STACK_NAME=dev
export REPO_OWNER=REPO_OWNER
export CONNECTION_ARN=ARN
export [email protected]
export BRANCH=BRANCH_NAME
```

4. (Optional) Set the optional feature to deploy the Point Cloud(PC) visualizer pipeline with environment variables `export pipelineActivatePCVisualizer=true` - the point cloud(PC) visualizer pipeline stack is for viewing Point Cloud files in the VAMS visualizer preview. You can optionally set this via CDK deploy context parameter. Note: This does deploy additional AWS components such as a VPC and EPV endpoints that may have additional static infrastructure costs.

5. Deploy the stack -
`cdk deploy`

6. This will deploy an AWS CodePipeline in your account and the pipeline will deploy AWS CloudFormation stacks to create resources for VAMS in your AWS account. After successful deployment, an account is created in an AWS Cognito User Pool using this email address. Expect an email from [email protected] with a temporary password.

![CI/CD](./diagrams/codepipeline.png)

#### Build and Deploy from local machine

VAMS Codebase is changing frequently and we recommend you checkout the stable released version from github.

Expand Down
8 changes: 8 additions & 0 deletions codepipeline/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out
6 changes: 6 additions & 0 deletions codepipeline/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
14 changes: 14 additions & 0 deletions codepipeline/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Welcome to your CDK TypeScript project

This is a blank project for CDK development with TypeScript.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

## Useful commands

- `npm run build` compile typescript to js
- `npm run watch` watch for changes and compile
- `npm run test` perform the jest unit tests
- `cdk deploy` deploy this stack to your default AWS account/region
- `cdk diff` compare deployed stack with current state
- `cdk synth` emits the synthesized CloudFormation template
29 changes: 29 additions & 0 deletions codepipeline/bin/codepipeline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node

/*
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import "source-map-support/register";
import * as cdk from "aws-cdk-lib";
import { AwsSolutionsChecks } from "cdk-nag";
import { Aspects } from "aws-cdk-lib";
import { CodePipelineStack } from "../lib/codepipeline";

const app = new cdk.App();
const region = process.env.AWS_REGION || "us-east-1";

/** development variables **/
const enableCdkNag = true;

if (enableCdkNag) {
Aspects.of(app).add(new AwsSolutionsChecks({ verbose: true }));
}

new CodePipelineStack(app, `vams-code-pipeline-${process.env.DEPLOYMENT_ENV || "dev"}`, {
stackName: `vams-code-pipeline-${process.env.DEPLOYMENT_ENV || "dev"}`,
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: region },
});

app.synth();
55 changes: 55 additions & 0 deletions codepipeline/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"app": "npx ts-node --prefer-ts-exts bin/codepipeline.ts",
"watch": {
"include": ["**"],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
"@aws-cdk/aws-route53-patters:useCertificate": true,
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
"@aws-cdk/aws-redshift:columnId": true,
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
"@aws-cdk/aws-kms:aliasNameRef": true,
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true
}
}
8 changes: 8 additions & 0 deletions codepipeline/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: "node",
roots: ["<rootDir>/test"],
testMatch: ["**/*.test.ts"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
};
Loading