@wheatstalk/cdk-unique-value-resource
v0.0.8
Published
 
Getting Started
To install a shared version of the resource provider, install and bootstrap AWS CDK, then type the following command:
cdk --app 'npx @wheatstalk/cdk-unique-value-resource' deploy UniqueValueResourceOnce this stack has deployed, you may add the dependency to your CDK app:
# Install with yarn
yarn add @wheatstalk/cdk-unique-value-resource
# Install with npm
npm install @wheatstalk/cdk-unique-value-resourceAfter which, you may start to use it immediately:
import {
UniqueValueProvider,
UniqueIntegerResource,
} from '@wheatstalk/cdk-unique-value-resource';
// Use the shared resource provider.
const provider = UniqueValueProvider.fromRegionalStack(this, 'UniqueValueProvider');
// Create a unique value
const uniqueInteger = new UniqueIntegerResource(this, 'UniqueInteger', {
provider,
// Guaranteed uniqueness in the group named 'testing'. You may use a fixed
// string value as like shown. You may also reference another resource,
// such as a load balancer listener rule's arn.
group: 'testing',
// Start at 10000, inclusive
start: 10000,
// Stop at 40000, exclusive
stop: 40000,
// Allocate unique numbers
step: 1,
});
// Display the unique value
new CfnOutput(this, 'UniqueIntegerValue', {
value: uniqueInteger.uniqueValue,
});To remove the shared version of the resource provider, type the following:
cdk --app 'npx @wheatstalk/cdk-unique-value-resource' destroy UniqueValueResourceNote: By design, CloudFormation will prevent the deletion of the resource provider stack unless you remove all references to the provider's custom resource type.
Architecture Notes
- CDK-based project
- Lambda-backed custom resource provider
- Lambda code written in Python
- Allocated values are tracked in a DynamoDB table
Development Notice
This project is still in development. We do not recommend using it in production until it is stable version 1.0.0. We do not have any estimates on when this may be.
Contributing
We're open to feedback on this project.
