Skip to content

Commit

Permalink
Update to v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eggoynes committed Oct 20, 2022
1 parent 4d680c1 commit a414cd5
Show file tree
Hide file tree
Showing 28 changed files with 734 additions and 92 deletions.
18 changes: 0 additions & 18 deletions .gitignore

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2022-10-17
### Added
- AppRegistry Application Stack Association
- Application Insights in AppRegistry
- SonarQube properties file: sonar-project.properties
- Added unit tests with 80% code coverage
### Changed
- Changed deployment/run-unit-tests.sh to generate unit test coverage reports
### Contributors
* @sandimciin
* @eggoynes

## [1.1.0] - 2021-7-29
### Added
Expand All @@ -22,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added extra steps when building in the Readme file. (https://github.com/awslabs/video-on-demand-on-aws-foundations/issues/4)
- Updated Axios to version 0.21.1

### Contributors
* @eggoynes
## [1.0.0] - 2020-11-05
### Added
- All files, initial version
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ reported the issue. Please try to include as much information as you can. Detail
## Contributing via Pull Requests
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:

1. You are working against the latest source on the *master* branch.
1. You are working against the latest source on the *main* branch.
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.

Expand Down Expand Up @@ -57,6 +57,6 @@ If you discover a potential security issue in this project we ask that you notif

## Licensing

See the [LICENSE](https://github.com/awslabs/%%SOLUTION_NAME%%/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
See the [LICENSE](https://github.com/awslabs/%%SOLUTION_NAME%%/blob/main/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.

We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ aws s3 mb s3://my-bucket-us-east-1
Build the distributable:
```
chmod +x ./build-s3-dist.sh
./build-s3-dist.sh my-bucket video-on-demand-on-aws-foundation v1.0.0
./build-s3-dist.sh my-bucket video-on-demand-on-aws-foundation v1.2.0
```

> **Notes**: The _build-s3-dist_ script expects the bucket name as one of its parameters, and this value should not include the region suffix.
Deploy the distributable to the Amazon S3 bucket in your account:
```
aws s3 cp ./regional-s3-assets/ s3://my-bucket-us-east-1/video-on-demand-on-aws-foundation/v1.0.0/ --recursive --acl bucket-owner-full-control
aws s3 cp ./regional-s3-assets/ s3://my-bucket-us-east-1/video-on-demand-on-aws-foundation/v1.2.0/ --recursive --acl bucket-owner-full-control
```

### 4. Launch the CloudFormation template.
Expand Down
7 changes: 5 additions & 2 deletions deployment/build-s3-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Parameters:
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
# code from. The template will append '-[region_name]' to this bucket name.
# For example: ./build-s3-dist.sh solutions my-solution v1.0.0
# For example: ./build-s3-dist.sh solutions my-solution v1.2.0
# The template will then expect the source code to be located in the solutions-[region_name] bucket
# - solution-name: name of the solution for consistency
# - version-code: version of the package
Expand All @@ -30,7 +30,7 @@ cdk_version=1.63.0
# Check to see if input has been provided:
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Please provide all required parameters for the build script"
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.0"
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.2.0"
exit 1
fi

Expand Down Expand Up @@ -71,6 +71,9 @@ npm install --production
echo "------------------------------------------------------------------------------"
echo "[Synth] CDK Project"
echo "------------------------------------------------------------------------------"
# Make sure user has the newest CDK version
npm uninstall -g aws-cdk && npm install -g aws-cdk@1

cd $source_dir/cdk
npm install
cdk synth --output=$staging_dist_dir
Expand Down
82 changes: 70 additions & 12 deletions deployment/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,73 @@
cd ../source/cdk
npm install --silent
npm test
#!/bin/bash

cd ../custom-resource
npm install --silent
npm test
[ "$DEBUG" == 'true' ] && set -x
set -e

cd ../job-submit
npm install --silent
npm test
prepare_jest_coverage_report() {
local component_name=$1

cd ../job-complete
npm install --silent
npm test
if [ ! -d "coverage" ]; then
echo "ValidationError: Missing required directory coverage after running unit tests"
exit 129
fi

# prepare coverage reports
rm -fr coverage/lcov-report
mkdir -p $coverage_reports_top_path/jest
coverage_report_path=$coverage_reports_top_path/jest/$component_name
rm -fr $coverage_report_path
mv coverage $coverage_report_path
}

run_javascript_test() {
local component_path=$1
local component_name=$2

echo "------------------------------------------------------------------------------"
echo "[Test] Run javascript unit test with coverage for $component_name"
echo "------------------------------------------------------------------------------"
echo "cd $component_path"
cd $component_path

# install dependencies
npm install --silent
# run unit tests
npm test



# prepare coverage reports
prepare_jest_coverage_report $component_name
}

# Get reference for all important folders
template_dir="$PWD"
source_dir="$template_dir/../source"
coverage_reports_top_path=$source_dir/test/coverage-reports

# Test the attached Lambda function
declare -a lambda_packages=(
"cdk"
"custom-resource"
"job-complete"
"job-submit"
)

for lambda_package in "${lambda_packages[@]}"
do
rm -rf $source_dir/$lambda_package/coverage
mkdir $source_dir/$lambda_package/coverage
run_javascript_test $source_dir/$lambda_package $lambda_package

# Check the result of the test and exit if a failure is identified
if [ $? -eq 0 ]
then
echo "Test for $lambda_package passed"
else
echo "******************************************************************************"
echo "Lambda test FAILED for $lambda_package"
echo "******************************************************************************"
exit 1
fi

done
2 changes: 1 addition & 1 deletion source/cdk/bin/vod-foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import * as cdk from '@aws-cdk/core';
import { VodFoundation } from '../lib/vod-foundation-stack';

const app = new cdk.App();
new VodFoundation(app, 'VodFoundation');
new VodFoundation(app, 'VodFoundation'); // NOSONAR
98 changes: 73 additions & 25 deletions source/cdk/lib/vod-foundation-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import * as iam from '@aws-cdk/aws-iam';
import * as lambda from '@aws-cdk/aws-lambda';
import * as subs from '@aws-cdk/aws-sns-subscriptions';
import { HttpMethods } from '@aws-cdk/aws-s3';
import * as appreg from '@aws-cdk/aws-servicecatalogappregistry';
import * as applicationinsights from '@aws-cdk/aws-applicationinsights';
/**
* AWS Solution Constructs: https://docs.aws.amazon.com/solutions/latest/constructs/
*/
Expand All @@ -18,11 +20,13 @@ export class VodFoundation extends cdk.Stack {
/**
* CloudFormation Template Descrption
*/
this.templateOptions.description = '(SO0146) v1.1.0: Video on Demand on AWS Foundation Solution Implementation';
const solutionId = 'SO0146'
const solutionName = 'Video on Demand on AWS Foundation'
this.templateOptions.description = '(SO0146) v1.2.0: Video on Demand on AWS Foundation Solution Implementation';
/**
* Mapping for sending anonymous metrics to AWS Solution Builders API
*/
new cdk.CfnMapping(this, 'Send', {
new cdk.CfnMapping(this, 'Send', { // NOSONAR
mapping: {
AnonymousUsage: {
Data: 'Yes'
Expand Down Expand Up @@ -173,12 +177,14 @@ export class VodFoundation extends cdk.Stack {
rules_to_suppress: [{
id: 'W58',
reason: 'Invalid warning: function has access to cloudwatch'
},{
id: 'W89',
reason: 'AWS Lambda does not require VPC for this solution.'
},{
id: 'W92',
reason: 'ReservedConcurrentExecutions not required'
},
{
id: 'W89',
reason: 'Invalid warning: lambda not needed in VPC'
},
{
id: 'W92',
reason: 'Invalid warning: lambda does not need ReservedConcurrentExecutions'
}]
}
};
Expand Down Expand Up @@ -237,13 +243,15 @@ export class VodFoundation extends cdk.Stack {
rules_to_suppress: [{
id: 'W58',
reason: 'Invalid warning: function has access to cloudwatch'
},{
},
{
id: 'W89',
reason: 'AWS Lambda does not require VPC for this solution.'
},{
reason: 'Invalid warning: lambda not needed in VPC'
},
{
id: 'W92',
reason: 'ReservedConcurrentExecutions not required'
}]
reason: 'Invalid warning: lambda does not need ReservedConcurrentExecutions'
}]
}
};
/**
Expand Down Expand Up @@ -290,20 +298,22 @@ export class VodFoundation extends cdk.Stack {
rules_to_suppress: [{
id: 'W58',
reason: 'Invalid warning: function has access to cloudwatch'
},{
},
{
id: 'W89',
reason: 'AWS Lambda does not require VPC for this solution.'
},{
reason: 'Invalid warning: lambda not needed in VPC'
},
{
id: 'W92',
reason: 'ReservedConcurrentExecutions not required'
}]
reason: 'Invalid warning: lambda does not need ReservedConcurrentExecutions'
}]
}
};
/**
* Custom resource to configure the source S3 bucket; upload default job-settings file and
* enabble event notifications to trigger the job-submit lambda function
*/
new cdk.CustomResource(this, 'S3Config', {
new cdk.CustomResource(this, 'S3Config', { // NOSONAR
serviceToken: customResourceLambda.functionArn,
properties: {
SourceBucket: source.bucketName,
Expand All @@ -314,7 +324,7 @@ export class VodFoundation extends cdk.Stack {
* Solution constructs, creates a CloudWatch event rule to trigger the process
* outputs lambda functions.
*/
new EventsRuleToLambda(this, 'EventTrigger', {
new EventsRuleToLambda(this, 'EventTrigger', { // NOSONAR
existingLambdaObj: jobComplete,
eventRuleProps: {
enabled: true,
Expand Down Expand Up @@ -344,33 +354,71 @@ export class VodFoundation extends cdk.Stack {
const snsTopic = new LambdaToSns(this, 'Notification', {
existingLambdaObj: jobSubmit
});
new LambdaToSns(this, 'CompleteSNS', {
new LambdaToSns(this, 'CompleteSNS', { // NOSONAR
existingLambdaObj: jobComplete,
existingTopicObj: snsTopic.snsTopic
});
/**
* Subscribe the admin email address to the SNS topic created but the construct.
*/
snsTopic.snsTopic.addSubscription(new subs.EmailSubscription(adminEmail.valueAsString))

/**
* AppRegistry
*/
const applicationName = `vod-foundation-${cdk.Aws.STACK_NAME}`;
const attributeGroup = new appreg.AttributeGroup(this, 'AppRegistryAttributeGroup', {
attributeGroupName: cdk.Aws.STACK_NAME,
description: "Attribute group for solution information.",
attributes: {
ApplicationType: 'AWS-Solutions',
SolutionVersion: '%%VERSION%%',
SolutionID: solutionId,
SolutionName: solutionName
}
});
const appRegistry = new appreg.Application(this, 'AppRegistryApp', {
applicationName: applicationName,
description: `Service Catalog application to track and manage all your resources. The SolutionId is ${solutionId} and SolutionVersion is %%VERSION%%.`
});
appRegistry.associateStack(this);
cdk.Tags.of(appRegistry).add('solutionId', solutionId);
cdk.Tags.of(appRegistry).add('SolutionName', solutionName);
cdk.Tags.of(appRegistry).add('SolutionDomain', 'CloudFoundations');
cdk.Tags.of(appRegistry).add('SolutionVersion', '%%VERSION%%');
cdk.Tags.of(appRegistry).add('appRegistryApplicationName', 'vod-foundation-stack');
cdk.Tags.of(appRegistry).add('ApplicationType', 'AWS-Solutions');

appRegistry.node.addDependency(attributeGroup);
appRegistry.associateAttributeGroup(attributeGroup);

const appInsights = new applicationinsights.CfnApplication(this, 'ApplicationInsightsApp', {
resourceGroupName: `AWS_AppRegistry_Application-${applicationName}`,
autoConfigurationEnabled: true,
cweMonitorEnabled: true,
opsCenterEnabled: true
});
appInsights.node.addDependency(appRegistry);

/**
* Stack Outputs
*/
new cdk.CfnOutput(this, 'SourceBucket', {
new cdk.CfnOutput(this, 'SourceBucket', { // NOSONAR
value: source.bucketName,
description: 'Source S3 Bucket used to host source video and MediaConvert job settings files',
exportName: `${ cdk.Aws.STACK_NAME}-SourceBucket`
});
new cdk.CfnOutput(this, 'DestinationBucket', {
new cdk.CfnOutput(this, 'DestinationBucket', { // NOSONAR
value: destination.bucketName,
description: 'Source S3 Bucket used to host all MediaConvert ouputs',
exportName: `${ cdk.Aws.STACK_NAME}-DestinationBucket`
});
new cdk.CfnOutput(this, 'CloudFrontDomain', {
new cdk.CfnOutput(this, 'CloudFrontDomain', { // NOSONAR
value: cloudFront.cloudFrontWebDistribution.distributionDomainName,
description: 'CloudFront Domain Name',
exportName: `${ cdk.Aws.STACK_NAME}-CloudFrontDomain`
});
new cdk.CfnOutput(this, 'SnsTopic', {
new cdk.CfnOutput(this, 'SnsTopic', { // NOSONAR
value: snsTopic.snsTopic.topicName,
description: 'SNS Topic used to capture the VOD workflow outputs including errors',
exportName: `${ cdk.Aws.STACK_NAME}-SnsTopic`
Expand Down
Loading

0 comments on commit a414cd5

Please sign in to comment.