@stackspot/cdk-core
v0.1.6
Published
Component to manage stack in SSM.
Downloads
3
Readme
CDK Core
Component to manage stack in SSM.
How to use
Below are all languages supported by the AWS CDK.
C#
Install the dependency:
dotnet add package StackSpot.Cdk.Core
Import the construct into your project, for example:
using Amazon.CDK;
using Constructs;
using StackSpot.Cdk.Core;
namespace MyStack
{
public class MyStack : Stack
{
internal MyStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
Resource resource = new Resource("resource-name", "resource-arn", "resource-stack-name");
// Save
StackManager.SaveResource(this, resource);
// Fetch
string myArn = StackManager.GetResourceArn(this, "resource-stack-name", "resource-name");
}
}
}
F#
Not yet supported.
Go
Not yet supported.
Java
Not yet supported.
JavaScript
Install the dependency:
npm install --save @stackspot/cdk-core
Import the construct into your project, for example:
const { Stack } = require('aws-cdk-lib');
const { IResource, Resource, StackManager } = require('@stackspot/cdk-core');
class MyStack extends Stack {
constructor(scope, id, props) {
super(scope, id, props);
const resource: IResource = new Resource(
'resource-name',
'resource-arn',
'resource-stack-name'
);
// Save
StackManager.saveResource(this, resource);
// Fetch
const myArn: string = StackManager.getResourceArn(
this,
'resource-stack-name',
'resource-name'
);
}
}
module.exports = { MyStack };
Python
Not yet supported.
TypeScript
Install the dependency:
npm install --save @stackspot/cdk-core
Import the construct into your project, for example:
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { IResource, Resource, StackManager } from '@stackspot/cdk-core';
export class MyStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const resource: IResource = new Resource(
'resource-name',
'resource-arn',
'resource-stack-name'
);
// Save
StackManager.saveResource(this, resource);
// Fetch
const myArn: string = StackManager.getResourceArn(
this,
'resource-stack-name',
'resource-name'
);
}
}
Construct Props
Resource
| Name | Type | Description | | --------- | ------ | --------------------------------- | | arn | string | The ARN of the resource. | | name | string | The name of the resource. | | stackName | string | The name of the resource's stack. |
Properties
Resource
| Name | Type | Description | | --------- | ------ | --------------------------------- | | arn | string | The ARN of the resource. | | name | string | The name of the resource. | | stackName | string | The name of the resource's stack. |
Methods
StackManager
| Name | Description | | ----------------------------------------------------- | ----------------------------------------- | | static getResourceArn(scope, stackName, resourceName) | Get the ARN of the resource saved in SSM. | | static saveResource(scope, resource) | Save resources in SSM. |
static getResourceArn(scope, stackName, resourceName)
public static getResourceArn(scope: Construct, stackName: string, resourceName: string): string
Parameters
- scope Construct
- stackName string
- resourceName string
Returns
- string
Get the ARN of the resource saved in SSM.
static saveResource(scope, resource)
public static saveResource(scope: Construct, resource: IResource): StringParameter
Parameters
Returns
Save resources in SSM.
IAM Least privilege
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DeleteParameter",
"ssm:GetParameters",
"ssm:PutParameter"
],
"Resource": "*"
}
]
}
Development
Prerequisites
- EditorConfig (Optional)
- Git
- Node.js 17
Setup
cd cdk-core-jsii-component
npm install
You are done! Happy coding!