Skip to content

Latest commit

 

History

History

cdk-temp-stack

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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/core';

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 { Construct } from '@aws-cdk/core';
import { Vpc } from '@aws-cdk/aws-ec2';
import { TempStack, TempStackProps } from '@cloudcomponents/cdk-temp-stack';

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 { Construct, Stack, StackProps, Duration } from '@aws-cdk/core';
import { TimeToLive } from '@cloudcomponents/cdk-temp-stack';

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