{"id":19024367,"url":"https://github.com/aws-solutions/cost-optimizer-for-amazon-workspaces","last_synced_at":"2026-03-17T17:17:29.576Z","repository":{"id":42173917,"uuid":"90175308","full_name":"aws-solutions/cost-optimizer-for-amazon-workspaces","owner":"aws-solutions","description":"This solution analyzes all of your Amazon WorkSpaces usage data and automatically converts the WorkSpace to the most cost-effective billing option (hourly or monthly), depending on your individual usage. Use this with a single account, or with AWS Organizations across multiple accounts, to help you monitor your WorkSpace usage and optimize costs.","archived":false,"fork":false,"pushed_at":"2025-01-27T19:35:01.000Z","size":1490,"stargazers_count":90,"open_issues_count":2,"forks_count":46,"subscribers_count":43,"default_branch":"main","last_synced_at":"2025-03-29T05:04:04.326Z","etag":null,"topics":["aws","aws-solutions","cost-optimization","device-managment","virtual-desktop-optimization-tool"],"latest_commit_sha":null,"homepage":"https://aws.amazon.com/solutions/implementations/cost-optimizer-for-amazon-workspaces/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aws-solutions.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-03T17:26:44.000Z","updated_at":"2025-03-22T00:09:59.000Z","dependencies_parsed_at":"2024-07-30T23:30:04.060Z","dependency_job_id":"98c3128a-6d37-41fe-8e6a-f243f7d5e4a8","html_url":"https://github.com/aws-solutions/cost-optimizer-for-amazon-workspaces","commit_stats":null,"previous_names":["aws-solutions/workspaces-cost-optimizer"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-solutions%2Fcost-optimizer-for-amazon-workspaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-solutions%2Fcost-optimizer-for-amazon-workspaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-solutions%2Fcost-optimizer-for-amazon-workspaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-solutions%2Fcost-optimizer-for-amazon-workspaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aws-solutions","download_url":"https://codeload.github.com/aws-solutions/cost-optimizer-for-amazon-workspaces/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294516,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-solutions","cost-optimization","device-managment","virtual-desktop-optimization-tool"],"created_at":"2024-11-08T20:36:33.177Z","updated_at":"2026-03-17T17:17:29.561Z","avatar_url":"https://github.com/aws-solutions.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"*[🚀 Solution Landing Page](https://aws.amazon.com/solutions/implementations/cost-optimizer-for-amazon-workspaces/)** | **[🚧 Feature request](https://github.com/aws-solutions/cost-optimizer-for-amazon-workspaces/issues/new?assignees=\u0026labels=feature-request%2C+enhancement\u0026template=feature_request.md\u0026title=)** | **[🐛 Bug Report](https://github.com/aws-solutions/cost-optimizer-for-amazon-workspaces/issues/new?assignees=\u0026labels=bug%2C+triage\u0026template=bug_report.md\u0026title=)**\n\nNote: If you want to use the solution without building from source, navigate to Solution Landing Page.\n\n## Table of contents\n\n- [Solution Overview](#solution-overview)\n- [Architecture Diagram](#architecture-diagram)\n- [Getting Started](#getting-started)\n- [Customizing the Solution](#customizing-the-solution)\n  - [Build](#build)\n  - [Unit Test](#unit-test)\n  - [Deploy](#deploy)\n- [File Structure](#file-structure)\n- [Collection of operational metrics](#collection-of-operational-metrics)\n- [License](#license)\n\n\u003ca name=\"solution-overview\"\u003e\u003c/a\u003e\n# Solution Overview\nAmazon WorkSpaces, a fully managed, secure virtual desktop computing service on the AWS Cloud, eliminates the need for customers to procure, deploy, and manage complex virtual desktop environments. Amazon WorkSpaces offers the flexibility to pay hourly or monthly without any up-front commitment.\n\nTo help customers with unpredictable WorkSpace usage patterns monitor their Amazon WorkSpaces usage and optimize costs, AWS offers the Amazon WorkSpaces Cost Optimizer, a solution that analyzes all of your WorkSpace usage data and automatically converts the WorkSpace to the most cost-effective billing option (hourly or monthly) depending on the user's individual usage. This solution is easy to deploy and gives a choice to use either [AWS Cloudformation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) or [AWS CDKv2](https://docs.aws.amazon.com/cdk/v2/guide/home.html) to automatically provision and configure the necessary AWS services.\n\n\u003ca name=\"architecture-diagram\"\u003e\u003c/a\u003e\n# Architecture Diagram\n![alt Architecture Diagram](source/architecture_diagram.png)\n\n\u003ca name=\"getting-started\"\u003e\u003c/a\u003e\n# Getting Started\nFor deployment flexability and backwards compatability, there are two ways of deploying this solution: via Cloudformation and via CDK. The simplest way to get started is via AWS Cloudformation's WebUI. The programatic way via CDK allows customization of input parameters. Feel free to choose either ways of deployment to fit your needs.\n\nDeploy via the [CloudFormation Template for WorkSpaces Cost Optimizer](https://solutions-reference.s3.amazonaws.com/cost-optimizer-for-amazon-workspaces/latest/cost-optimizer-for-amazon-workspaces.template)\n\nDeploy via [CDKv2](https://docs.aws.amazon.com/cdk/v2/guide/home.html) with [npm](https://docs.npmjs.com/):\n\n\n[Preconfigure aws profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)\n```\ngit clone git@github.com:aws-solutions/cost-optimizer-for-amazon-workspaces.git\n\n\ncd source\n\nnpm install\n\n# set your preconfigured aws profile in ~/.aws/credentials\nexport AWS_PROFILE=\"\"\nexport DIST_OUTPUT_BUCKET=solutions\n\nnpm run bootstrap -- --profile ${AWS_PROFILE}\n\nnpm run deploy -- --profile ${AWS_PROFILE} --parameters CreateNewVPC=Yes\n```\n\n\nFor the full solution overview visit [WorkSpaces Cost Optimizer on AWS](https://aws.amazon.com/solutions/implementations/cost-optimizer-for-amazon-workspaces/)\n\n\u003ca name=\"aws-solutions-constructs\"\u003e\u003c/a\u003e\u003ca name=\"customizing-the-solution\"\u003e\u003c/a\u003e\n# Customizing the Solution\n\n\u003ca name=\"build\"\u003e\u003c/a\u003e\n## Build\n\nClone the repository\n\n```\ngit clone git@github.com:aws-solutions/cost-optimizer-for-amazon-workspaces.git\n```\n\nCreate a distribution S3 bucket with the format `MY-BUCKET-\u003caws_region\u003e`. The solution's cdk will expect the\nsource code to be located in this bucket. `\u003caws_region\u003e` is where you are testing the customized solution.\n\nNote: When you create a bucket, a randomized value unique to your environment is recommended for the bucket name.\nAs a best practice, enable the server side encryption and also block public access to the bucket.\n\n```\nexport TEMPLATE_OUTPUT_BUCKET=\u003cYOUR_TEMPLATE_BUCKET_NAME\u003e\nexport DIST_OUTPUT_BUCKET=\u003cYOUR_DIST_BUCKET_NAME\u003e\nexport SOLUTION_NAME=\"cost-optimizer-for-amazon-workspaces\"\nexport VERSION=\u003cVERSION\u003e\n## NOTE THAT the region is appended to the DIST_BUCKET_NAME (DIST_BUCKET_NAME-REGION) when deployed, so creating a bucket with only Bucket_Name will not work.\n```\n\nChange the working directory to the deployment folder.\n\n```\ncd deployment\n```\n\nRun the build script.\n\n```\nchmod +x ./build-s3-dist.sh \u0026\u0026 ./build-s3-dist.sh $TEMPLATE_OUTPUT_BUCKET $DIST_OUTPUT_BUCKET $SOLUTION_NAME $VERSION\n```\n\nUpload the artifacts.\n\n```\naws s3 cp ./dist/ s3://$BUCKET_NAME-[region]/cost-optimizer-for-amazon-workspaces/$VERSION --recursive\n```\n\nYou should now have everything in place to run cdk or CloudFormation template(either from your bucket or from `./deployment/dist/`).\n\n\u003ca name=\"unit-test\"\u003e\u003c/a\u003e\n## Unit Test\n```\nchmod +x \"./run-unit-tests.sh\" \u0026\u0026 \"./run-unit-tests.sh\"\n```\n\n\u003ca name=\"deploy\"\u003e\u003c/a\u003e\n## Deploy\nTwo methods of deploying: CDK or CloudFormation Template\n1. CDK: Run as seen in getting started section and then deploy spoke in a separate aws account\n```\nAWS_PROFILE=\"\"\nAWS_PROFILE_SPOKE=\"\"\n\n# Note: running bootstrap is only required once, not needed for every subsequent deployment.\nnpm run bootstrap -- --profile ${AWS_PROFILE}\n\nnpm run deploy -- --profile ${AWS_PROFILE} --parameters CreateNewVPC=Yes\n\nHUB_ACCOUNT_ID=$(aws sts get-caller-identity --profile $AWS_PROFILE_SPOKE --query Account --output text)\n\nnpm run bootstrap -- --profile ${AWS_PROFILE_SPOKE} --parameter HubAccountId=$HUB_ACCOUNT_ID\n\nnpm run deploySpoke -- --profile ${AWS_PROFILE_SPOKE} --parameters HubAccountId=${HUB_ACCOUNT_ID}\n\n```\n\n2. Cloudformation: For backwards compatibility, generate CloudFormation templates into source/cdk.out/ directory. Get the link of the cost-optimizer-for-amazon-workspaces.template loaded to your Amazon S3 bucket. Deploy the Workspaces Cost Optimizer solution to your account by launching a new AWS CloudFormation stack using the link of the cost-optimizer-for-amazon-workspaces.template.\n:\n```\nnpm run synth\n\n#  source/cdk.out/{cost-optimizer-for-amazon-workspaces.template.json, cost-optimizer-for-amazon-workspaces-spoke.template.json}\n```\n\n\n\n\u003ca name=\"file-structure\"\u003e\u003c/a\u003e\n# File structure\n\n\u003cpre\u003e\n├── CHANGELOG.md\n├── CODE_OF_CONDUCT.md\n├── CONTRIBUTING.md\n├── LICENSE.txt\n├── NOTICE.txt\n├── README.md\n├── SECURITY.md\n├── buildspec.yml\n├── deployment\n│   ├── build-open-source-dist.sh\n│   ├── build-s3-dist.sh\n│   ├── run-unit-tests.sh\n│   └── upload-s3-dist.sh\n└── source\n    ├── Dockerfile\n    ├── bin\n    │   └── cost-optimizer-for-amazon-workspaces-solution.ts\n    ├── cdk.json\n    ├── lambda\n    │   ├── account_registration_provider\n    │   │   ├── __init__.py\n    │   │   ├── __tests__\n    │   │   │   ├── __init__.py\n    │   │   │   ├── conftest.py\n    │   │   │   └── test_account_registration_provider.py\n    │   │   └── account_registration_provider.py\n    │   ├── register_spoke_lambda\n    │   │   ├── __init__.py\n    │   │   ├── __tests__\n    │   │   │   ├── __init__.py\n    │   │   │   ├── conftest.py\n    │   │   │   ├── test_dynamodb.py\n    │   │   │   ├── test_register_spoke_accounts.py\n    │   │   │   └── test_request_event.py\n    │   │   ├── dynamodb_table.py\n    │   │   ├── register_spoke_accounts.py\n    │   │   └── request_event.py\n    │   ├── utils\n    │   │   ├── __tests__\n    │   │   │   ├── __init__.py\n    │   │   │   ├── conftest.py\n    │   │   │   └── test_cfnresponse.py\n    │   │   └── cfnresponse.py\n    │   └── uuid_generator\n    │       ├── __init__.py\n    │       ├── __tests__\n    │       │   ├── __init__.py\n    │       │   ├── conftest.py\n    │       │   └── test_uuid_generator.py\n    │       └── uuid_generator.py\n    ├── lib\n    │   ├── cdk-helper\n    │   │   ├── add-cfn-nag-suppression.ts\n    │   │   ├── condition-aspect.ts\n    │   │   ├── override-logical-id.ts\n    │   │   └── set-condition.ts\n    │   ├── components\n    │   │   ├── dashboard-resources.ts\n    │   │   ├── ecs-cluster-resources.ts\n    │   │   ├── register-spoke-account-resources.ts\n    │   │   ├── usage-report-bucket-resources.ts\n    │   │   ├── uuid-resources.ts\n    │   │   └── vpc-resources.ts\n    │   ├── cost-optimizer-for-amazon-workspaces-hub-stack.ts\n    │   └── cost-optimizer-for-amazon-workspaces-spoke-stack.ts\n    ├── package.json\n    ├── package-lock.json\n    ├── poetry.lock\n    ├── pyproject.toml\n    ├── tsconfig.json\n    └── workspaces_app\n        ├── main.py\n        ├── test_workspaces_app.py\n        └── workspaces_app\n            ├── __init__.py\n            ├── __tests__\n            │   ├── __init__.py\n            │   ├── conftest.py\n            │   ├── test_account_registry.py\n            │   ├── test_directory_reader.py\n            │   ├── test_metrics_helper.py\n            │   ├── test_user_session.py\n            │   ├── test_workspace_record.py\n            │   └── test_workspaces_helper.py\n            ├── account_registry.py\n            ├── directory_reader.py\n            ├── metrics_helper.py\n            ├── user_session.py\n            ├── workspace_record.py\n            ├── workspaces_helper.py\n            └── utils\n                ├── __init__.py\n                ├── __tests__\n                │   ├── __init__.py\n                │   ├── conftest.py\n                │   ├── test_dashboard_metrics.py\n                │   ├── test_date_utils.py\n                │   ├── test_s3_utils.py\n                │   ├── test_timer.py\n                │   ├── test_usage_table_dao.py\n                │   └── test_user_session_dao.py\n                ├── dashboard_metrics.py\n                ├── date_utils.py\n                ├── decimal_encoder.py\n                ├── s3_utils.py\n                ├── solution_metrics.py\n                ├── timer.py\n                ├── usage_table_dao.py\n                ├── user_session_dao.py\n                └── workspace_utils.py\n\u003c/pre\u003e\n\n\n################################################\n\n\u003ca name=\"collection-of-operational-metrics\"\u003e\u003c/a\u003e\n# Collection of operational metrics\n\nThis solution collects anonymized operational metrics to help AWS improve the\nquality of features of the solution. For more information, including how to disable\nthis capability, please see the\n[Implementation Guide](https://docs.aws.amazon.com/solutions/latest/cost-optimizer-for-workspaces/anonymized-data-collection.html)\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n# License\n\nSee license\n[here](https://github.com/aws-solutions/cost-optimizer-for-amazon-workspaces/blob/main/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-solutions%2Fcost-optimizer-for-amazon-workspaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faws-solutions%2Fcost-optimizer-for-amazon-workspaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-solutions%2Fcost-optimizer-for-amazon-workspaces/lists"}