Skip to main content

A stack that destroys itself after a given time (ttl)

Project description

cloudcomponents Logo

@cloudcomponents/cdk-temp-stack

Build Status cdkdx typescript python

A stack that destroys itself after a given time (ttl)

Install

TypeScript/JavaScript:

npm i @cloudcomponents/cdk-temp-stack

Python:

pip install cloudcomponents.cdk-temp-stack

How to use

// temp-infra-app.ts

#!/usr/bin/env node

import 'source-map-support/register';
import { App, Duration } from 'aws-cdk-lib';

import { TempInfraStack } from './temp-infra-stack';

const app = new App();

new TempInfraStack(app, 'TempInfraStack', {
  env: {
    region: process.env.DEFAULT_REGION,
    account: process.env.CDK_DEFAULT_ACCOUNT,
  },
  ttl: Duration.minutes(10),
});

// temp-infra-stack.ts

import { TempStack, TempStackProps } from '@cloudcomponents/cdk-temp-stack';
import { Vpc } from 'aws-cdk-lib/aws-ec2';
import { Construct } from 'constructs';

export class TempInfraStack extends TempStack {
  constructor(scope: Construct, id: string, props: TempStackProps) {
    super(scope, id, props);

    new Vpc(this, 'VPC');
  }
}

TimeToLive Construct

Alternatively, you can also add the TimeToLive construct to your stack

// your stack

import { TimeToLive } from '@cloudcomponents/cdk-temp-stack';
import { Stack, StackProps, Duration } from 'aws-cdk-lib';
import { Construct } from 'constructs';

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

    new TimeToLive(this, 'TimeToLive', {
      ttl: Duration.minutes(10),
    });
  }
}

API Reference

See API.md.

Example

See more complete examples.

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudcomponents.cdk-temp-stack-2.3.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cloudcomponents.cdk-temp-stack-2.3.0.tar.gz.

File metadata

File hashes

Hashes for cloudcomponents.cdk-temp-stack-2.3.0.tar.gz
Algorithm Hash digest
SHA256 47b0ef31be686d5d1a7ad0ba941afc895ba19b01ba81f1cdc68debe0d2344ae4
MD5 383b9d53676df915e23aa8e46d779778
BLAKE2b-256 c250ea5b6105ee3a8a297205ec475ae90318c1e752f776063326a60fb89815e2

See more details on using hashes here.

File details

Details for the file cloudcomponents.cdk_temp_stack-2.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudcomponents.cdk_temp_stack-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad8ac9eec0e9d4cec7b853cfbc2f9ef9917785b8486a4bd18a3a5eb8f9473628
MD5 4febb266de981e242cca3ebefaaa916f
BLAKE2b-256 2503ac67588496041b947a532a454ef5952215224c6c622526ac7795866b1238

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page