Skip to content

Commit

Permalink
Merge pull request #26 from deolank/release-candidate/v2.4.0
Browse files Browse the repository at this point in the history
Updated to version v2.4.0
  • Loading branch information
hnishar authored Sep 27, 2021
2 parents d27b925 + 102a850 commit 7b7d155
Show file tree
Hide file tree
Showing 13 changed files with 2,216 additions and 586 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

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).
## [2.4] - 2021-09
### Fixed
- Fixed the bug to correctly calculate billable hours if user disconnects workspace within autostop timeout

### Added
- Feature to terminate unused workspaces
- Generate aggregated reports
- Feature to specify AWS Regions to monitor
- Support for Gov cloud partition

## [2.3] - 2021-06
### Fixed
Expand Down
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,9 @@ Deploy the Workspaces Cost Optimizer solution to your account by launching a new
|-README.md
</pre>

<a name="Collection of operational metrics"></a>
# Collection of operational metrics

This solution collects anonymous operational metrics to help AWS improve the quality and features of the solution. For more information, including how to disable this capability, please see the [implementation guide](https://docs.aws.amazon.com/solutions/latest/workspaces-cost-optimizer/collection-of-operational-metrics.html).

<a name="license"></a>
# License

See license [here](https://github.com/awslabs/workspaces-cost-optimizer/blob/master/LICENSE.txt)







################################################




-------------
## Optimization Engine

Expand Down
27 changes: 26 additions & 1 deletion deployment/build-s3-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ source_dir="$template_dir/../source"

# There are now TWO dist directories
template_dist_dir="$template_dir/global-s3-assets"
build_dist_dir="$template_dir/regional-s3-assets"
build_dist_dir="$template_dir/regional-s3-assets"

wco_folder="$template_dir/ecr/workspaces-cost-optimizer"

echo "------------------------------------------------------------------------------"
echo "[Init] Clean old dist and template folders"
Expand All @@ -49,6 +51,9 @@ rm -rf $build_dist_dir
echo "mkdir -p $build_dist_dir"
mkdir -p $build_dist_dir

echo "mkdir -p $wco_folder"
mkdir -p $wco_folder

echo "------------------------------------------------------------------------------"
echo "[Packing] Template"
echo "------------------------------------------------------------------------------"
Expand All @@ -64,6 +69,16 @@ SUB4="s/%VERSION%/$4/g"

sed -e $SUB1 -e $SUB2 -e $SUB3 -e $SUB4 ./$TEMPLATE > $template_dist_dir/$TEMPLATE

echo "***** public ECR registry: $PUBLIC_ECR_REGISTRY"
replace="s|PUBLIC_ECR_REGISTRY|$PUBLIC_ECR_REGISTRY|g" # "|" is used as a delimiter because $PUBLIC_ECR_REGISTRY includes "/"
echo "sed -i -e $replace"
sed -i -e $replace $template_dist_dir/$TEMPLATE

echo "***** public ECR tag: $PUBLIC_ECR_TAG"
replace="s/PUBLIC_ECR_TAG/$PUBLIC_ECR_TAG/g"
echo "sed -i -e $replace"
sed -i -e $replace $template_dist_dir/$TEMPLATE

# Build Lambda zip
echo "------------------------------------------------------------------------------"
echo "[Packing] lambda code"
Expand All @@ -76,3 +91,13 @@ ls -alt
zip -q -r9 $build_dist_dir/workspaces-cost-optimizer.zip .
echo "Completed building distribution"
cd $template_dir


echo "------------------------------------------------------------------------------"
echo "[Copying] Dockerfile and code artifacts to deployment/ecr folder"
echo "------------------------------------------------------------------------------"

echo "$source_dir/Dockerfile $wco_folder"
cp $source_dir/Dockerfile $wco_folder
echo "-r $source_dir/ecs $wco_folder"
cp -r $source_dir/ecs $wco_folder
63 changes: 40 additions & 23 deletions deployment/workspaces-cost-optimizer.template
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ Parameters:
AllowedValues:
- "Yes"
- "No"
Regions:
Type: String
Description: The list of AWS regions which the solution will scan. Example - us-east-1, us-west-2. Leave blank to scan all regions.
TerminateUnusedWorkspaces:
Type: String
Description: Select "Yes" to terminate Workspaces not used for a month.
Default: "No"
AllowedValues:
- "Yes"
- "No"
- "Dry Run"
ValueLimit:
Type: Number
Description: The number of hours a Value instance can run in a month before being converted to ALWAYS_ON. Default is 81.
Expand Down Expand Up @@ -134,6 +145,14 @@ Metadata:
- GraphicsProLimit
- PowerLimit
- PowerProLimit
- Label:
default: List of AWS Regions
Parameters:
- Regions
- Label:
default: Terminate unused workspaces
Parameters:
- TerminateUnusedWorkspaces
ParameterLabels:
VpcCIDR:
default: "AWS Fargate VPC CIDR Block"
Expand All @@ -157,6 +176,10 @@ Metadata:
default: "Subnet ID for second subnet"
ExistingSecurityGroupId:
default: "Security group ID to launch ECS task"
Regions:
default: "List of AWS Regions"
TerminateUnusedWorkspaces:
default: "Terminate workspaces not used for a month"

Mappings:
Solution:
Expand All @@ -169,9 +192,7 @@ Mappings:
SendAnonymousUsageData: True
MetricsURL: "https://metrics.awssolutionsbuilder.com/generic"
AutoStopTimeoutHours: 1
Image: "898061675696.dkr.ecr.us-east-1.amazonaws.com/wco:2.3.0"
ECRRepository: "arn:aws:ecr:us-east-1:898061675696:repository/wco"

Image: PUBLIC_ECR_REGISTRY/workspaces-cost-optimizer:PUBLIC_ECR_TAG

Conditions:
CreateNewVPC: !Equals
Expand Down Expand Up @@ -208,36 +229,28 @@ Resources:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: !Join ["", ["arn:aws:logs:", Ref: "AWS::Region", ":", Ref: "AWS::AccountId", ":log-group:/ecs/wco-task/*"]]
Resource: !Join ["", ["arn:", Ref: "AWS::Partition", ":logs:", Ref: "AWS::Region", ":", Ref: "AWS::AccountId", ":log-group:/ecs/wco-task/*"]]
- Effect: Allow
Action:
- ecr:GetAuthorizationToken
Resource: "*"
- Effect: Allow
Action:
- ecr:BatchCheckLayerAvailability
- ecr:BatchGetImage
- ecr:GetDownloadUrlForLayer
Resource: !FindInMap [Solution, Data, "ECRRepository"]
- Effect: Allow
Action:
- workspaces:DescribeTags
- workspaces:DescribeWorkspaces
- workspaces:DescribeWorkspaceDirectories
- workspaces:ModifyWorkspaceProperties
- workspaces:TerminateWorkspaces
- workspaces:DescribeWorkspacesConnectionStatus
Resource:
- !Sub "arn:aws:workspaces:*:${AWS::AccountId}:directory/*"
- !Sub "arn:aws:workspaces:*:${AWS::AccountId}:workspace/*"
- !Sub "arn:aws:workspaces:*:${AWS::AccountId}:workspacebundle/*"
- !Sub "arn:${AWS::Partition}:workspaces:*:${AWS::AccountId}:directory/*"
- !Sub "arn:${AWS::Partition}:workspaces:*:${AWS::AccountId}:workspace/*"
- !Sub "arn:${AWS::Partition}:workspaces:*:${AWS::AccountId}:workspacebundle/*"
- Effect: Allow
Action:
- s3:PutObject
Resource:
!Join
- ''
- - 'arn:aws:s3:::'
- !Ref CostOptimizerBucket
- /*
Resource:
- !Sub "arn:${AWS::Partition}:s3:::${CostOptimizerBucket}/*"
- Effect: Allow
Action:
- cloudwatch:GetMetricStatistics
Expand Down Expand Up @@ -277,11 +290,11 @@ Resources:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: !Join ["", ["arn:aws:logs:", Ref: "AWS::Region", ":", Ref: "AWS::AccountId", ":log-group:/aws/lambda/*"]]
Resource: !Sub "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/{AWS::Partition}/lambda/*"
- Effect: Allow
Action:
- ecs:RunTask
Resource: !Join [":", [ "arn:aws:ecs", !Ref "AWS::Region", !Ref "AWS::AccountId", "task-definition/wco-task" ] ]
Resource: !Sub "arn:${AWS::Partition}:ecs:${AWS::Region}:${AWS::AccountId}:task-definition/wco-task"
- Effect: Allow
Action:
- iam:PassRole
Expand Down Expand Up @@ -554,6 +567,10 @@ Resources:
Version: !FindInMap [Solution, Data, "Version"]
- Name: AutoStopTimeoutHours
Value: !FindInMap [Solution, Data, "AutoStopTimeoutHours"]
- Name: Regions
Value: !Ref Regions
- Name: TerminateUnusedWorkspaces
Value: !Ref TerminateUnusedWorkspaces

LogConfiguration:
LogDriver: "awslogs"
Expand Down Expand Up @@ -607,7 +624,7 @@ Resources:
Type: AWS::Events::Rule
Properties:
Description: Rule to trigger WorkSpacesCostOptimizer function on a schedule.
ScheduleExpression: cron(55 23 * * ? *)
ScheduleExpression: cron(00 23 * * ? *)
State: ENABLED
Targets:
- Arn: !GetAtt CostOptimizerCreateTaskFunction.Arn
Expand Down Expand Up @@ -671,7 +688,7 @@ Resources:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: !Join ["", ["arn:aws:logs:", Ref: "AWS::Region", ":", Ref: "AWS::AccountId", ":log-group:/aws/lambda/*"]]
Resource: !Join ["", ["arn:", Ref: "AWS::Partition", ":logs:", Ref: "AWS::Region", ":", Ref: "AWS::AccountId", ":log-group:/", Ref: "AWS::Partition", "/lambda/*"]]
- Effect: Allow
Action:
- iam:PassRole
Expand Down
Loading

0 comments on commit 7b7d155

Please sign in to comment.