Skip to content

Commit d9208dd

Browse files
author
Mike O'Brien
committed
Update to version v1.4.0
1 parent cc31291 commit d9208dd

Some content is hidden

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

60 files changed

+819
-355
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [1.4.0] - 2021-04-26
8+
### Added
9+
- Enable solution to be deployed as mutliple stacks in the same account/region
10+
### Fixed
11+
- Fix the SSM Maintenance window issue where solution was not fetching SSM Maintenance windows from other account/regions
12+
- Updated logging utility to remove incorrect timestamp
13+
- Fixed issue with scheduler stopping instances at UTC time even when configured with other timezones and Period having weekday configured as Wed#4. [Github Issue](https://github.com/awslabs/aws-instance-scheduler/issues/238)
14+
- Modified Anonymous Data reporting refer implementation guide for details.
15+
- Removed redundant logging of UTC timestamp along with the Account/Region default stamp in logs in AWS CloudWatch.
16+
- Fixed [Github Issue](https://github.com/awslabs/aws-instance-scheduler/issues/184) for scheduler-cli.
17+
618
## [1.3.3] - 2020-08-31
19+
### Fixed
720
- Update the project to utilize aws cdk constructs for cloudformation template creation.
821
- Fix the issue for ensuring throttling is avoided to cloudwatch API's from github PR [#177](https://github.com/awslabs/aws-instance-scheduler/pull/177)
922
## [1.3.2] - 2020-06-22

README.md

+9-11
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,28 @@ wget https://github.com/awslabs/aws-instance-scheduler/archive/master.zip
3838

3939
```
4040
|- deployment/ - contains build scripts, deployment templates, and dist folders for staging assets.
41-
|- cdk-solution-helper/ - helper function for converting CDK output to a format compatible with the AWS Solutions pipelines.
4241
|- build-open-source-dist.sh - builds the open source package with cleaned assets and builds a .zip file in the /open-source folder for distribution to GitHub
4342
|- build-s3-dist.sh - builds the solution and copies artifacts to the appropriate /global-s3-assets or /regional-s3-assets folders.
4443
|- run-unit-tests.sh - runs the unit tests for the lambda files.
4544
|- source/ - all source code, scripts, tests, etc.
4645
|- bin/
4746
|- aws-instance-scheduler.ts - the AWS Instance scheduler cdk app.
47+
|- cli/ - scheduler-cli source files.
4848
|- lambda/ - Lambda function with source code and test cases.
4949
|- lib/
5050
|- aws-instance-scheduler-stack.ts - the main CDK stack for aws instance scheduler solution.
5151
|- aws-instance-scheduler-remote-stack.ts - the main CDK stack for aws instance scheduler solution remote template.
5252
|- test/
5353
|- __snapshots__/
54-
|- aws-instance-scheduler-remote-stack.test.ts - unit and snapshot tests for aws instance scheduler.
54+
|- aws-instance-scheduler-remote-stack.test.ts - unit and snapshot tests for aws instance scheduler remote stack.
5555
|- aws-instance-scheduler-stack.test.ts - unit and snapshot tests for aws instance scheduler.
5656
|- cdk.json - config file for CDK.
5757
|- jest.config.js - config file for unit tests.
5858
|- package.json - package file for the aws instance scheduler CDK project.
5959
|- README.md - doc file for the CDK project.
6060
|- run-all-tests.sh - runs all tests within the /source folder. Referenced in the buildspec and build scripts.
61+
|- tsconfig.json - typescript configurations.
6162
|- .gitignore
62-
|- .viperlightignore - Viperlight scan ignore configuration (accepts file, path, or line item).
63-
|- .viperlightrc - Viperlight scan configuration.
64-
|- buildspec.yml - main build specification for CodeBuild to perform builds and execute unit tests.
6563
|- CHANGELOG.md - required for every solution to include changes based on version to auto-build release notes.
6664
|- CODE_OF_CONDUCT.md - standardized open source file for all solutions.
6765
|- CONTRIBUTING.md - standardized open source file for all solutions.
@@ -81,7 +79,7 @@ AWS Solutions use two buckets: a bucket for global access to templates, which is
8179

8280
**Build the solution**
8381

84-
From the *deployment* folder in your cloned repo, run build-s3-dist.sh, passing the root name of your bucket (ex. mybucket), name of the solution i.e. aws-instance-scheduler and the version you are building (ex. v1.3.3). We recommend using a similar version based on the version downloaded from GitHub (ex. GitHub: v1.3.3, your build: v1.3.3.mybuild)
82+
From the *deployment* folder in your cloned repo, run build-s3-dist.sh, passing the root name of your bucket (ex. mybucket), name of the solution i.e. aws-instance-scheduler and the version you are building (ex. v1.4.0). We recommend using a similar version based on the version downloaded from GitHub (ex. GitHub: v1.4.0, your build: v1.4.0.mybuild)
8583

8684
```
8785
chmod +x build-s3-dist.sh
@@ -102,18 +100,18 @@ Confirm that all unit tests pass.
102100

103101
Upload the template and the lambda to your bucket in the following pattern,
104102
```
105-
s3://mybucket-us-east-1/aws-instance-scheduler/v1.3.3/instance-scheduler.zip (lambda Code)
103+
s3://mybucket-us-east-1/aws-instance-scheduler/v1.4.0/instance-scheduler.zip (lambda Code)
106104
```
107105

108106
Templates
109107
```
110-
s3://mybucket/aws-instance-scheduler/v1.3.3/instance-scheduler.template
111-
s3://mybucket/aws-instance-scheduler/v1.3.3/instance-scheduler-remote.template
108+
s3://mybucket/aws-instance-scheduler/v1.4.0/instance-scheduler.template
109+
s3://mybucket/aws-instance-scheduler/v1.4.0/instance-scheduler-remote.template
112110
```
113111

114112
## Deploy
115113

116-
See the [AWS Instance Scheduler Implementation Guide](https://s3.amazonaws.com/solutions-reference/aws-instance-scheduler/latest/instance-scheduler.pdf) for deployment instructions, using the link to the instance-scheduler.template from your bucket, rather than the one for AWS Solutions. Ex. https://mybucket.s3.amazonaws.com/aws-instance-scheduler/v1.3.3.mybuild/instance-scheduler.template
114+
See the [AWS Instance Scheduler Implementation Guide](https://s3.amazonaws.com/solutions-reference/aws-instance-scheduler/latest/instance-scheduler.pdf) for deployment instructions, using the link to the instance-scheduler.template from your bucket, rather than the one for AWS Solutions. Ex. https://mybucket.s3.amazonaws.com/aws-instance-scheduler/v1.4.0.mybuild/instance-scheduler.template
117115

118116
## CDK Documentation
119117

@@ -122,7 +120,7 @@ AWS Instance Scheduler templates are generated using AWS CDK, for further inform
122120

123121
***
124122

125-
Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
123+
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
126124

127125
Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
128126

deployment/build-open-source-dist.sh

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ source_dir="$source_template_dir/../source"
2323
github_dir="$source_template_dir/../.github"
2424
dist_template_dir="$dist_dir/deployment"
2525

26+
2627
echo "------------------------------------------------------------------------------"
2728
echo "[Init] Remove any old dist files from previous runs"
2829
echo "------------------------------------------------------------------------------"

deployment/build-s3-dist.sh

+31-35
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
#!/bin/bash
22
#
3-
# This script packages your project into a solution distributable that can be
4-
# used as an input to the solution builder validation pipeline.
5-
#
6-
# This script will perform the following tasks:
7-
# 1. Remove any old dist files from previous runs.
8-
# 2. Install dependencies for the cdk-solution-helper; responsible for
9-
# converting standard 'cdk synth' output into solution assets.
10-
# 3. Build and synthesize your CDK project.
11-
# 4. Run the cdk-solution-helper on template outputs and organize
12-
# those outputs into the /global-s3-assets folder.
13-
# 5. Organize source code artifacts into the /regional-s3-assets folder.
14-
# 6. Remove any temporary files used for staging.
3+
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
6+
# with the License. A copy of the License is located at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
11+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
12+
# and limitations under the License.
1513
#
16-
# Parameters:
17-
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
18-
# code from. The template will append '-[region_name]' to this bucket name.
19-
# For example: ./build-s3-dist.sh solutions v1.0.0
20-
# The template will then expect the source code to be located in the solutions-[region_name] bucket
21-
# - solution-name: name of the solution for consistency
22-
# - version-code: version of the package
2314

2415
# Important: CDK global version number
25-
cdk_version=1.53.0
16+
cdk_version=1.96.0
2617

2718
# Check to see if the required parameters have been provided:
2819
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
@@ -44,6 +35,10 @@ template_dist_dir="$template_dir/global-s3-assets"
4435
build_dist_dir="$template_dir/regional-s3-assets"
4536
source_dir="$template_dir/../source"
4637

38+
39+
[ "$DEBUG" == 'true' ] && set -x
40+
set -e
41+
4742
echo "------------------------------------------------------------------------------"
4843
echo "[Init] Remove any old dist files from previous runs"
4944
echo "------------------------------------------------------------------------------"
@@ -68,8 +63,8 @@ echo "--------------------------------------------------------------------------
6863
# Install the global aws-cdk package
6964
echo "cd $source_dir"
7065
cd $source_dir
71-
echo "npm install -g aws-cdk@$cdk_version"
72-
npm install -g aws-cdk@$cdk_version
66+
echo "npm install aws-cdk@$cdk_version"
67+
npm install aws-cdk@$cdk_version
7368

7469
echo "------------------------------------------------------------------------------"
7570
echo "NPM Install in the source folder"
@@ -79,18 +74,11 @@ echo "--------------------------------------------------------------------------
7974
echo "npm install"
8075
npm install
8176

82-
# Run npm run build && npm run test for the cdk component unit tests
83-
echo "npm run build && npm run test"
84-
npm run build && npm run test
85-
86-
# Run all the python tests.
87-
echo "$template_dir/run-unit-tests.sh"
88-
$template_dir/run-unit-tests.sh
89-
90-
9177
# Run 'cdk synth' to generate raw solution outputs
92-
echo "cdk synth --output=$staging_dist_dir"
93-
cdk synth --output=$staging_dist_dir
78+
echo "cd "$source_dir""
79+
cd "$source_dir"
80+
echo "node_modules/aws-cdk/bin/cdk synth --output=$staging_dist_dir"
81+
npm run build && node_modules/aws-cdk/bin/cdk synth --output=$staging_dist_dir --no-version-reporting
9482

9583
# Remove unnecessary output files
9684
echo "cd $staging_dist_dir"
@@ -128,7 +116,7 @@ mv version.py version.py.org
128116
sed "s/%version%/$DIST_VERSION/g" version.py.org > version.py
129117

130118
echo "Install all the python dependencies in the staging directory before packaging"
131-
pip install -r $source_dir/lambda/requirements.txt -t $staging_dist_dir/lambda/
119+
pip install -U -r $source_dir/lambda/requirements.txt -t $staging_dist_dir/lambda/
132120

133121
echo "Build lambda distribution packaging"
134122
zip -q --recurse-paths ./instance-scheduler.zip version.txt main.py version.py configuration/* requesthandlers/* chardet/* urllib3/* idna/* requests/* schedulers/* util/* boto_retry/* models/* pytz/* certifi/*
@@ -139,7 +127,15 @@ echo "cd into the scheduler cli folder ./cli"
139127

140128
cd ../cli
141129
echo "Build the scheduler cli package"
142-
zip -q --recurse-paths ./scheduler-cli.zip scheduler-cli/* setup.py instance-scheduler-cli-runner.py
130+
mv ./setup.py ./setup.bak.py
131+
echo "update the version in setup.py"
132+
sed "s/#version#/$DIST_VERSION/g" ./setup.bak.py > ./setup.py
133+
rm setup.bak.py
134+
echo "update the version in scheduler_cli.py"
135+
mv ./scheduler_cli/scheduler_cli.py ./scheduler_cli/scheduler_cli.bak.py
136+
sed "s/#version#/$DIST_VERSION/g" ./scheduler_cli/scheduler_cli.bak.py > ./scheduler_cli/scheduler_cli.py
137+
rm ./scheduler_cli/scheduler_cli.bak.py
138+
zip -q --recurse-paths ./scheduler-cli.zip scheduler_cli/* setup.py instance-scheduler-cli-runner.py
143139

144140
echo "Copy the scheduler cli package to $build_dist_dir"
145141
cp -pr ./scheduler-cli.zip $build_dist_dir/

source/bin/aws-instance-scheduler.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,25 @@ import { AwsInstanceSchedulerStack } from '../lib/aws-instance-scheduler-stack';
1919
import { AwsInstanceSchedulerRemoteStack } from '../lib/aws-instance-scheduler-remote-stack';
2020

2121
const SOLUTION_VERSION = process.env['DIST_VERSION'] || '%%VERSION%%';
22-
const SOLUTION_NAME = process.env['SOLUTION_NAME'];
23-
const SOLUTION_ID = process.env['SOLUTION_ID'];
24-
const SOLUTION_BUCKET = process.env['DIST_OUTPUT_BUCKET'];
25-
const SOLUTION_TMN = process.env['SOLUTION_TRADEMARKEDNAME'];
22+
const SOLUTION_NAME = process.env['SOLUTION_NAME'] ? process.env['SOLUTION_NAME'] : "aws-instance-scheduler";
23+
const SOLUTION_ID = process.env['SOLUTION_ID'] ? process.env['SOLUTION_ID'] : "SO0030";
24+
const SOLUTION_BUCKET = process.env['DIST_OUTPUT_BUCKET'] ? process.env['DIST_OUTPUT_BUCKET'] : "";
25+
const SOLUTION_TMN = process.env['SOLUTION_TRADEMARKEDNAME'] ? process.env['SOLUTION_TRADEMARKEDNAME'] : "aws-instance-scheduler";
2626
const SOLUTION_PROVIDER = 'AWS Solution Development';
2727

2828
const app = new cdk.App();
2929

30-
31-
new AwsInstanceSchedulerStack(app, 'instance-scheduler', {
32-
description: '(' + SOLUTION_ID + ') - ' + SOLUTION_NAME + ', version ' + SOLUTION_VERSION,
30+
new AwsInstanceSchedulerStack(app, 'aws-instance-scheduler', {
31+
description: `(${SOLUTION_ID}) - The AWS CloudFormation template for deployment of the ${SOLUTION_NAME}, version: ${SOLUTION_VERSION}`,
3332
solutionId: SOLUTION_ID,
3433
solutionTradeMarkName: SOLUTION_TMN,
3534
solutionProvider: SOLUTION_PROVIDER,
3635
solutionBucket: SOLUTION_BUCKET,
3736
solutionName: SOLUTION_NAME,
3837
solutionVersion: SOLUTION_VERSION
3938
});
40-
new AwsInstanceSchedulerRemoteStack(app, 'instance-scheduler-remote', {
41-
description: '(' + SOLUTION_ID + ') - ' + SOLUTION_NAME + ' cross account role, version ' + SOLUTION_VERSION,
39+
new AwsInstanceSchedulerRemoteStack(app, 'aws-instance-scheduler-remote', {
40+
description: `(${SOLUTION_ID}S) - The AWS CloudFormation template for ${SOLUTION_NAME} cross account role, version: ${SOLUTION_VERSION}`,
4241
solutionId: SOLUTION_ID,
4342
solutionTradeMarkName: SOLUTION_TMN,
4443
solutionProvider: SOLUTION_PROVIDER,

source/cli/instance-scheduler-cli-runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################################################################################################################
2-
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
2+
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
33
# #
44
# Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance #
55
# with the License. A copy of the License is located at #

source/cli/scheduler_cli/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################################################################################################################
2-
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
2+
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
33
# #
44
# Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance #
55
# with the License. A copy of the License is located at #

source/cli/scheduler_cli/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################################################################################################################
2-
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
2+
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
33
# #
44
# Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance #
55
# with the License. A copy of the License is located at #

source/cli/scheduler_cli/scheduler_cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################################################################################################################
2-
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
2+
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
33
# #
44
# Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance #
55
# with the License. A copy of the License is located at #

source/cli/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################################################################################################################
2-
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
2+
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
33
# #
44
# Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance #
55
# with the License. A copy of the License is located at #

source/lambda/Instance-scheduler.json

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"ParameterKey": "Trace",
2020
"ParameterValue": "Yes"
2121
},
22+
{
23+
"ParameterKey": "EnableSSMaintenanceWindows",
24+
"ParameterValue": "No"
25+
},
2226
{
2327
"ParameterKey": "TagName",
2428
"ParameterValue": "Schedule"

source/lambda/bin/chardetect

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/root/.pyenv/versions/3.8.1/bin/python3.8
1+
#!/root/.pyenv/versions/3.8.8/bin/python3.8
22
# -*- coding: utf-8 -*-
33
import re
44
import sys

source/lambda/boto_retry/__init__.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################################################################################################################
2-
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
2+
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. #
33
# #
44
# Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance #
55
# with the License. A copy of the License is located at #
@@ -150,10 +150,11 @@ def get_client_with_retries(service_name, methods, context=None, region=None, se
150150
if region is not None:
151151
args["region_name"] = region
152152

153-
user_agent = os.getenv("USER_AGENT", None)
154-
if user_agent is not None:
155-
session_config = botocore.config.Config(user_agent=user_agent)
156-
args["config"] = session_config
153+
user_agent_extra_string = os.getenv("USER_AGENT_EXTRA", None)
154+
if user_agent_extra_string is not None:
155+
solution_config = {"user_agent_extra": user_agent_extra_string}
156+
config = botocore.config.Config(**solution_config)
157+
args["config"] = config
157158

158159
aws_session = session if session is not None else boto3.Session()
159160

0 commit comments

Comments
 (0)