{"id":14986837,"url":"https://github.com/nideveloper/cdk-spa-deploy","last_synced_at":"2025-04-04T13:07:38.315Z","repository":{"id":38553663,"uuid":"231734093","full_name":"nideveloper/CDK-SPA-Deploy","owner":"nideveloper","description":"This is an AWS CDK Construct to make deploying a single page website (Angular/React/Vue) to AWS S3 behind SSL/Cloudfront easier","archived":false,"fork":false,"pushed_at":"2023-04-25T14:57:42.000Z","size":2782,"stargazers_count":233,"open_issues_count":34,"forks_count":40,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T12:08:09.895Z","etag":null,"topics":["angular-cli","aws-cdk","aws-cdk-construct","cdk","cloudfront","jsii","python","reactjs","ssl"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nideveloper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-04T08:46:45.000Z","updated_at":"2025-03-03T20:48:53.000Z","dependencies_parsed_at":"2024-06-19T04:11:08.103Z","dependency_job_id":"cfdd6599-74b9-422b-a20a-dbcdeada8826","html_url":"https://github.com/nideveloper/CDK-SPA-Deploy","commit_stats":{"total_commits":250,"total_committers":23,"mean_commits":"10.869565217391305","dds":0.632,"last_synced_commit":"bb67fa99523e150774122e059d792f2f901f8c44"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nideveloper%2FCDK-SPA-Deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nideveloper%2FCDK-SPA-Deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nideveloper%2FCDK-SPA-Deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nideveloper%2FCDK-SPA-Deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nideveloper","download_url":"https://codeload.github.com/nideveloper/CDK-SPA-Deploy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246026111,"owners_count":20711580,"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":["angular-cli","aws-cdk","aws-cdk-construct","cdk","cloudfront","jsii","python","reactjs","ssl"],"created_at":"2024-09-24T14:13:38.953Z","updated_at":"2025-03-28T12:08:16.208Z","avatar_url":"https://github.com/nideveloper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CDK-SPA-Deploy\r\n[![npm](https://img.shields.io/npm/dt/cdk-spa-deploy)](https://www.npmjs.com/package/cdk-spa-deploy)\r\n[![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/cdk-spa-deploy)](https://www.npmjs.com/package/cdk-spa-deploy)\r\n\r\nThis is an AWS CDK Construct to make deploying a single page website (Angular/React/Vue) to AWS S3 behind SSL/Cloudfront as easy as 5 lines of code.\r\n\r\n\r\n## Installation and Usage\r\n\r\n### Typescript\r\n\r\n```console\r\nnpm install --save cdk-spa-deploy\r\n```\r\n\r\nThere is now a v1 and a v2 CDK version of this construct\r\n\r\n#### For AWS CDK V1 Usage:\r\n\r\nAs of version 103.0 this construct now declares peer dependencies rather than bundling them so you can use it with any version of CDK higher than 103.0 without waiting on me to release a new version. The downside is that you will need to install the dependencies it uses for yourself, here is a list:\r\n```json\r\n{\r\n    \"constructs\": \"^3.3.75\",\r\n    \"@aws-cdk/aws-certificatemanager\": \"^1.103.0\",\r\n    \"@aws-cdk/aws-cloudfront\": \"^1.103.0\",\r\n    \"@aws-cdk/aws-iam\": \"^1.103.0\",\r\n    \"@aws-cdk/aws-route53\": \"^1.103.0\",\r\n    \"@aws-cdk/aws-route53-patterns\": \"^1.103.0\",\r\n    \"@aws-cdk/aws-route53-targets\": \"^1.103.0\",\r\n    \"@aws-cdk/aws-s3\": \"^1.103.0\",\r\n    \"@aws-cdk/aws-s3-deployment\": \"^1.103.0\",\r\n    \"@aws-cdk/core\": \"^1.103.0\"\r\n}\r\n```\r\n\r\n#### For AWS CDK V2 usage:\r\nInstall v2.0.0-alpha.1 and use it like below based on your chosen language, no extra steps\r\n\r\n```typescript\r\nimport * as cdk from '@aws-cdk/core';\r\nimport { SPADeploy } from 'cdk-spa-deploy';\r\n\r\nexport class CdkStack extends cdk.Stack {\r\n  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {\r\n    super(scope, id, props);\r\n\r\n    new SPADeploy(this, 'spaDeploy')\r\n      .createBasicSite({\r\n        indexDoc: 'index.html',\r\n        websiteFolder: '../blog/dist/blog'\r\n      });\r\n\r\n    new SPADeploy(this, 'cfDeploy')\r\n      .createSiteWithCloudfront({\r\n        indexDoc: 'index.html',\r\n        websiteFolder: '../blog/dist/blog'\r\n      });\r\n  }\r\n}\r\n\r\n```\r\n\r\n### Python\r\n```console\r\npip install cdk-spa-deploy\r\n```\r\n\r\nNote As of version 103.0 this construct now declares peer dependencies rather than bundling them so you can use it with any version of CDK higher than 103.0 without waiting on me to release a new version. The downside is that you will need to install the dependencies it uses for yourself. The npm versioms are listed above.\r\n\r\n```python\r\nfrom aws_cdk import core\r\nfrom spa_deploy import SPADeploy\r\n\r\nclass PythonStack(core.Stack):\r\n  def __init__(self, scope: core.Construct, id: str, **kwargs) -\u003e None:\r\n    super().__init__(scope, id, **kwargs)\r\n\r\n    SPADeploy(self, 'spaDeploy').create_basic_site(\r\n      index_doc='index.html',\r\n      website_folder='../blog/blog/dist/blog'\r\n    )\r\n\r\n\r\n    SPADeploy(self, 'cfDeploy').create_site_with_cloudfront(\r\n      index_doc='index.html',\r\n      website_folder='../blog/blog/dist/blog'\r\n    )\r\n```\r\n\r\n### Dotnet / C#\r\n\r\nThis project has now been published to nuget, more details to follow soon but you can find it [here](https://www.nuget.org/packages/CDKSPADeploy/1.80.0)\r\n\r\nNote As of version 103.0 this construct now declares peer dependencies rather than bundling them so you can use it with any version of CDK higher than 103.0 without waiting on me to release a new version. The downside is that you will need to install the dependencies it uses for yourself. The npm versioms are listed above.\r\n\r\n```bash\r\n# package manager\r\nInstall-Package CDKSPADeploy -Version 1.80.0\r\n# .NET CLI\r\ndotnet add package CDKSPADeploy --version 1.80.0\r\n# Package reference\r\n\u003cPackageReference Include=\"CDKSPADeploy\" Version=\"1.80.0\" /\u003e\r\n# Paket CLI\r\npaket add CDKSPADeploy --version 1.80.0\r\n```\r\n\r\n### Java\r\n\r\nA version has now been published to maven.\r\n\r\nNote As of version 103.0 this construct now declares peer dependencies rather than bundling them so you can use it with any version of CDK higher than 103.0 without waiting on me to release a new version. The downside is that you will need to install the dependencies it uses for yourself. The npm versioms are listed above.\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003ecom.cdkpatterns\u003c/groupId\u003e\r\n  \u003cartifactId\u003eCDKSPADeploy\u003c/artifactId\u003e\r\n  \u003cversion\u003e1.81.0\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n## Advanced Usage\r\n\r\n### Auto Deploy From Hosted Zone Name\r\n\r\nIf you purchased your domain through route 53 and already have a hosted zone then just use the name to deploy your site behind cloudfront. This handles the SSL cert and everything for you.\r\n\r\n```typescript\r\nnew SPADeploy(this, 'spaDeploy', { encryptBucket: true })\r\n  .createSiteFromHostedZone({\r\n    zoneName: 'cdkpatterns.com',\r\n    indexDoc: 'index.html',\r\n    websiteFolder: '../website/dist/website'\r\n  });\r\n\r\n```\r\n\r\n### Custom Domain and SSL Certificates\r\n\r\nYou can also pass the ARN for an SSL certification and your alias routes to cloudfront\r\n\r\n```typescript\r\nimport cdk = require('@aws-cdk/core');\r\nimport { SPADeploy } from 'cdk-spa-deploy';\r\n\r\nexport class CdkStack extends cdk.Stack {\r\n  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {\r\n    super(scope, id, props);\r\n\r\n    new SPADeploy(this, 'cfDeploy')\r\n      .createSiteWithCloudfront({\r\n        indexDoc: '../blog/dist/blog',\r\n        certificateARN: 'arn:...',\r\n        cfAliases: ['www.alias.com']\r\n      });\r\n  }  \r\n}\r\n\r\n```\r\n\r\n### Encrypted S3 Bucket\r\n\r\nPass in one boolean to tell SPA Deploy to encrypt your website bucket\r\n\r\n```typescript\r\nnew SPADeploy(this, 'cfDeploy', {encryptBucket: true}).createBasicSite({\r\n    indexDoc: 'index.html',\r\n    websiteFolder: 'website'\r\n});\r\n\r\n```\r\n\r\n### Custom Origin Behaviors\r\n\r\nPass in an array of CloudFront Behaviors \r\n\r\n```typescript\r\nnew SPADeploy(this, 'cfDeploy').createSiteWithCloudfront({\r\n  indexDoc: 'index.html',\r\n  websiteFolder: 'website',\r\n  cfBehaviors: [\r\n    {\r\n      isDefaultBehavior: true,\r\n      allowedMethods: cf.CloudFrontAllowedMethods.ALL,\r\n      forwardedValues: {\r\n        queryString: true,\r\n        cookies: { forward: 'all' },\r\n        headers: ['*'],\r\n      },\r\n    },\r\n    {\r\n      pathPattern: '/virtual-path',\r\n      allowedMethods: cf.CloudFrontAllowedMethods.GET_HEAD,\r\n      cachedMethods: cf.CloudFrontAllowedCachedMethods.GET_HEAD,\r\n    },\r\n  ],\r\n});\r\n```\r\n\r\n### Restrict Access to Known IPs\r\n\r\nPass in a boolean and an array of IP addresses and your site is locked down!\r\n\r\n```typescript\r\nnew SPADeploy(stack, 'spaDeploy', { \r\n  encryptBucket: true, \r\n  ipFilter: true, \r\n  ipList: ['1.1.1.1']\r\n}).createBasicSite({\r\n    indexDoc: 'index.html',\r\n    websiteFolder: 'website'\r\n  })\r\n```\r\n\r\n### Modifying S3 Bucket Created in Construct\r\n\r\nAn object is now returned containing relevant artifacts created if you need to make any further modifications:\r\n  * The S3 bucket is present for all of the methods\r\n  * When a CloudFront Web distribution is created it will be present in the return object\r\n\r\n```typescript\r\nexport interface SPADeployment {\r\n  readonly websiteBucket: s3.Bucket,\r\n}\r\n\r\nexport interface SPADeploymentWithCloudFront extends SPADeployment {\r\n  readonly distribution: CloudFrontWebDistribution,\r\n}\r\n```\r\n\r\n## Issues / Feature Requests\r\n\r\nhttps://github.com/nideveloper/CDK-SPA-Deploy\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnideveloper%2Fcdk-spa-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnideveloper%2Fcdk-spa-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnideveloper%2Fcdk-spa-deploy/lists"}