cloudcomponents.cdk-static-website


Namecloudcomponents.cdk-static-website JSON
Version 2.2.0 PyPI version JSON
download
home_pagehttps://github.com/cloudcomponents/cdk-constructs
SummaryCdk component that creates a static website using S3, configures CloudFront (CDN) and maps a custom domain via Route53 (DNS)
upload_time2024-05-16 19:33:14
maintainerNone
docs_urlNone
authorhupe1980
requires_python~=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)

# @cloudcomponents/cdk-static-website

[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)
[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)
[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-static-website)
[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-static-website/)
[![Mentioned in Awesome CDK](https://awesome.re/mentioned-badge.svg)](https://github.com/kolomied/awesome-cdk)

> Cdk component that creates a static website using S3, configures CloudFront (CDN) and maps a custom domain via Route53 (DNS)

## Install

TypeScript/JavaScript:

```bash
npm i @cloudcomponents/cdk-static-website
```

Python:

```bash
pip install cloudcomponents.cdk-static-website
```

## How to use

```python
import { StaticWebsite } from '@cloudcomponents/cdk-static-website';
import { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';
import { Construct } from 'constructs';

export class StaticWebsiteStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {
      domainName: 'cloudcomponents.org',
    });

    new StaticWebsite(this, 'StaticWebsite', {
      hostedZone,
      domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],
      removalPolicy: RemovalPolicy.DESTROY,
    });
  }
}
```

### Single page application (SPA)

```python
import { StaticWebsite } from '@cloudcomponents/cdk-static-website';
import { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';
import { Construct } from 'constructs';

export class StaticWebsiteStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {
      domainName: 'cloudcomponents.org',
    });

    new StaticWebsite(this, 'StaticWebsite', {
      hostedZone,
      domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],
      errorResponses: [
        {
          httpStatus: 404,
          responseHttpStatus: 200,
          ttl: props.ttl ?? Duration.seconds(300),
          responsePagePath: '/index.html',
        },
      ],
      removalPolicy: RemovalPolicy.DESTROY,
    });
  }
}
```

### Lambda at edge

```python
import { StaticWebsite } from '@cloudcomponents/cdk-static-website';
import { OriginMutation } from '@cloudcomponents/cdk-lambda-at-edge-pattern';
import { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';

import { Construct } from 'constructs';

export class StaticWebsiteStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {
      domainName: 'cloudcomponents.org',
    });

    const originMutation = new OriginMutation(stack, 'OriginMutation');

    new StaticWebsite(this, 'StaticWebsite', {
      hostedZone,
      domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],
      edgeLambdas: [originMutation],
      removalPolicy: RemovalPolicy.DESTROY,
    });
  }
}
```

## API Reference

See [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-static-website/API.md).

## Example

See more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).

## License

[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-static-website/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cloudcomponents/cdk-constructs",
    "name": "cloudcomponents.cdk-static-website",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "hupe1980",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/59/93/00685c228f8254a26d4af444dea375f84559cdca2b2d46f2d057535fde88/cloudcomponents.cdk-static-website-2.2.0.tar.gz",
    "platform": null,
    "description": "[![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)\n\n# @cloudcomponents/cdk-static-website\n\n[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)\n[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)\n[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-static-website)\n[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-static-website/)\n[![Mentioned in Awesome CDK](https://awesome.re/mentioned-badge.svg)](https://github.com/kolomied/awesome-cdk)\n\n> Cdk component that creates a static website using S3, configures CloudFront (CDN) and maps a custom domain via Route53 (DNS)\n\n## Install\n\nTypeScript/JavaScript:\n\n```bash\nnpm i @cloudcomponents/cdk-static-website\n```\n\nPython:\n\n```bash\npip install cloudcomponents.cdk-static-website\n```\n\n## How to use\n\n```python\nimport { StaticWebsite } from '@cloudcomponents/cdk-static-website';\nimport { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';\nimport { Construct } from 'constructs';\n\nexport class StaticWebsiteStack extends Stack {\n  constructor(scope: Construct, id: string, props: StackProps) {\n    super(scope, id, props);\n\n    const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {\n      domainName: 'cloudcomponents.org',\n    });\n\n    new StaticWebsite(this, 'StaticWebsite', {\n      hostedZone,\n      domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],\n      removalPolicy: RemovalPolicy.DESTROY,\n    });\n  }\n}\n```\n\n### Single page application (SPA)\n\n```python\nimport { StaticWebsite } from '@cloudcomponents/cdk-static-website';\nimport { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';\nimport { Construct } from 'constructs';\n\nexport class StaticWebsiteStack extends Stack {\n  constructor(scope: Construct, id: string, props: StackProps) {\n    super(scope, id, props);\n\n    const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {\n      domainName: 'cloudcomponents.org',\n    });\n\n    new StaticWebsite(this, 'StaticWebsite', {\n      hostedZone,\n      domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],\n      errorResponses: [\n        {\n          httpStatus: 404,\n          responseHttpStatus: 200,\n          ttl: props.ttl ?? Duration.seconds(300),\n          responsePagePath: '/index.html',\n        },\n      ],\n      removalPolicy: RemovalPolicy.DESTROY,\n    });\n  }\n}\n```\n\n### Lambda at edge\n\n```python\nimport { StaticWebsite } from '@cloudcomponents/cdk-static-website';\nimport { OriginMutation } from '@cloudcomponents/cdk-lambda-at-edge-pattern';\nimport { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';\n\nimport { Construct } from 'constructs';\n\nexport class StaticWebsiteStack extends Stack {\n  constructor(scope: Construct, id: string, props: StackProps) {\n    super(scope, id, props);\n\n    const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {\n      domainName: 'cloudcomponents.org',\n    });\n\n    const originMutation = new OriginMutation(stack, 'OriginMutation');\n\n    new StaticWebsite(this, 'StaticWebsite', {\n      hostedZone,\n      domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],\n      edgeLambdas: [originMutation],\n      removalPolicy: RemovalPolicy.DESTROY,\n    });\n  }\n}\n```\n\n## API Reference\n\nSee [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-static-website/API.md).\n\n## Example\n\nSee more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).\n\n## License\n\n[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-static-website/LICENSE)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cdk component that creates a static website using S3, configures CloudFront (CDN) and maps a custom domain via Route53 (DNS)",
    "version": "2.2.0",
    "project_urls": {
        "Homepage": "https://github.com/cloudcomponents/cdk-constructs",
        "Source": "https://github.com/cloudcomponents/cdk-constructs.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f053b548dabcb27779d5430daa1fade70d750d3df0f3fb0c127607553a056136",
                "md5": "746480193b3a0bfd68010a22f16bfc2b",
                "sha256": "49818ac095064b15fcb5d6f04d02ac0a54f1b374fe39f57eca65338ebb4124f7"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk_static_website-2.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "746480193b3a0bfd68010a22f16bfc2b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 149440,
            "upload_time": "2024-05-16T19:33:05",
            "upload_time_iso_8601": "2024-05-16T19:33:05.186066Z",
            "url": "https://files.pythonhosted.org/packages/f0/53/b548dabcb27779d5430daa1fade70d750d3df0f3fb0c127607553a056136/cloudcomponents.cdk_static_website-2.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "599300685c228f8254a26d4af444dea375f84559cdca2b2d46f2d057535fde88",
                "md5": "95a19d161448a0a4e865aafda179d9ed",
                "sha256": "795498e2644319ec66efd49da065cdb1b4bc971eba10cc6e49360a8df1c45510"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk-static-website-2.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "95a19d161448a0a4e865aafda179d9ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 151163,
            "upload_time": "2024-05-16T19:33:14",
            "upload_time_iso_8601": "2024-05-16T19:33:14.083633Z",
            "url": "https://files.pythonhosted.org/packages/59/93/00685c228f8254a26d4af444dea375f84559cdca2b2d46f2d057535fde88/cloudcomponents.cdk-static-website-2.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-16 19:33:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloudcomponents",
    "github_project": "cdk-constructs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cloudcomponents.cdk-static-website"
}
        
Elapsed time: 8.89790s