@alma-cdk/project 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.jsii CHANGED
@@ -3672,7 +3672,7 @@
3672
3672
  },
3673
3673
  "name": "@alma-cdk/project",
3674
3674
  "readme": {
3675
- "markdown": "<div align=\"center\">\n\t<br/>\n\t<br/>\n <h1>\n\t<img width=\"300\" src=\"assets/alma-cdk-project.svg\" alt=\"Alma CDK Project\" />\n <br/>\n <br/>\n </h1>\n\n ![NPM License](https://img.shields.io/npm/l/%40alma-cdk%2Fproject)\n [![release](https://github.com/alma-cdk/project/actions/workflows/release.yml/badge.svg)](https://github.com/alma-cdk/project/actions/workflows/release.yml)\n\n ```sh\n npm i -D @alma-cdk/project\n ```\n\n <div align=\"left\">\n\n Opinionated CDK “framework” with constructs & utilities for:\n - deploying multiple environments to multiple accounts (with many-to-many relationship)\n - managing account configuration through standardized props (no more random config files)\n - querying account and/or environment specific information within your CDK code\n - enabling dynamic & short-lived “feature-environments”\n - enabling well-defined tagging\n - providing structure & common conventions to CDK projects\n - choosing the target account & environment by passing in runtime context:\n\n ```sh\n npx cdk deploy -c account=dev -c environment=feature/abc-123\n ```\n ... which means you don't need to define all the possibile environments ahead of time!\n\n </div>\n <br/>\n</div>\n\n\n## Account Strategies\n\nDepending on the use case, you may choose a configuration between 1-3 AWS accounts with the following environments:\n\n\n1. **Shared account (`shared`)**:\n\n ![default-multi](assets/accounts-1x.svg)\n <br/>\n\n2. **Multi-account (`dev`+`prod`)**_– RECOMMENDED_:\n\n ![default-multi](assets/accounts-2x.svg)\n <br/>\n\n<br/>\n</details>\n\n3. **Multi-account (`dev`+`preprod`+`prod`)**:\n\n ![default-multi](assets/accounts-3x.svg)\n <br/>\n\n<br/>\n\n## Getting Started\n\nSteps required to define a _environmental_ project resources; At first, it might seem complex but once you get into the habbit of defining your projects this way it starts to make sense:\n\n1. Choose your [Account Strategy](#account-strategies)\n\n2. Initialize a new `Project` instead of `cdk.App`:\n\n ```ts\n // bin/app.ts\n import { Project, AccountStrategy } from '@alma-cdk/project';\n\n const project = new Project({\n // Basic info, you could also read these from package.json if you want\n name: 'my-cool-project',\n author: {\n organization: 'Acme Corp',\n name: 'Mad Scientists',\n email: 'mad.scientists@acme.example.com',\n },\n\n // If not set, defaults to one of: $CDK_DEFAULT_REGION, $AWS_REGION or us-east-1\n defaultRegion: 'eu-west-1',\n\n // Configures the project to use 2 AWS accounts (recommended)\n accounts: AccountStrategy.two({\n dev: {\n id: '111111111111',\n config: {\n // whatever you want here as [string]: any\n baseDomain: 'example.net',\n },\n },\n prod: {\n id: '222222222222',\n config: {\n // whatever you want here as [string]: any\n baseDomain: 'example.com',\n },\n },\n }),\n })\n ```\n\n3. Define a stack which `extends SmartStack` with resources:\n ```ts\n // lib/my-stack.ts\n import { Construct } from 'constructs';\n import { StackProps, RemovalPolicy } from 'aws-cdk-lib';\n import { SmartStack, Name, UrlName, PathName, EC } from '@alma-cdk/project';\n\n export class MyStack extends SmartStack {\n constructor(scope: Construct, id: string, props: StackProps) {\n super(scope, id, props);\n\n new dynamodb.Table(this, 'Table', {\n removalPolicy: EC.isStable(this) ? RemovalPolicy.RETAIN : RemovalPolicy.DESTROY,\n\n tableName: Name.it(this, 'MyTable'),\n partitionKey: {\n type: dynamodb.AttributeType.STRING,\n name: 'pk',\n },\n // StagingMyTable\n });\n\n new events.EventBus(this, 'EventBus', {\n eventBusName: Name.withProject(this, 'MyEventBus'),\n // MyCoolProjectStagingMyEventBus\n });\n\n new s3.Bucket(this, 'Bucket', {\n\n removalPolicy: EC.isStable(this) ? RemovalPolicy.RETAIN : RemovalPolicy.DESTROY,\n autoDeleteObjects: EC.isStable(this) ? false : true,\n\n bucketName: UrlName.globally(this, 'MyBucket'),\n // acme-corp-my-cool-project-feature-foo-bar-my-bucket\n });\n\n new ssm.StringParameter(this, 'Parameter', {\n stringValue: 'Foo',\n tier: ssm.ParameterTier.ADVANCED,\n parameterName: PathName.withProject(this, 'MyNamespace/MyParameter'),\n // /MyCoolProject/Staging/MyNamespace/MyParameter\n });\n }\n }\n ```\n\n4. Define a new _environmental_ which `extends EnvironmentWrapper` and initialize all your environmental `SmartStack` stacks within:\n\n ```ts\n // lib/environment.ts\n import { Construct } from 'constructs';\n import { EnvironmentWrapper } from '@alma-cdk/project';\n import { MyStack } from './my-stack';\n\n export class Environment extends EnvironmentWrapper {\n constructor(scope: Construct) {\n super(scope);\n new MyStack(this, 'MyStack', { description: 'This is required' });\n }\n }\n ```\n\n Resulting Stack properties (given `environment=staging`):\n\n | Property | Example value |\n | :---------------------- | :--------------------------------------------------- |\n | `stackName` | `\"MyCoolProject-Environment-Staging-MyExampleStack\"` |\n | `terminationProtection` | `true` |\n | `env.account` | `\"111111111111\"` |\n | `env.region` | `\"eu-west-1\"` |\n\n Resulting Tags for the Stack and its resources (given `environment=staging`):\n\n | Property | Example value |\n | :---------------------- | :-------------------------------- |\n | `Account` | `dev` |\n | `Environment` | `staging` |\n | `Project` | `my-cool-project` |\n | `Author` | `Mad Scientists` |\n | `Organization` | `Acme Corp` |\n | `Contact` | `mad.scientists@acme.example.com` |\n\n5. Finally initialize the environment with the `Project` scope:\n\n ```ts\n // bin/app.ts\n import { Project, Accounts } from '@alma-cdk/project';\n import { Environment } from '../lib/environment';\n\n const project = new Project({/* removed for brevity, see step 1 */})\n\n new Environment(project);\n ```\n\n<br/>\n\n\n## Documentation\n\nSee detailed documentation for specific classes & methods at [constructs.dev](http://constructs.dev/packages/@alma-cdk/project).\n\nGenerally speaking you would be most interested in the following:\n- Project\n- AccountStrategy\n- SmartStack\n- AccountWrapper & EnvironmentWrapper\n- AccountContext (AC)\n- EnvironmentContext (EC)\n- Name / UrlName / PathName\n\n## Migration\n\n### v0 to v1\n\n#### Tagging behavior\n\nDue to a bug in `v0`, the `Contact` and `Organization` tags were NOT applied as they should have. This means that by default, upgrading from v0→v1 introduces CloudFormation diff. Basically adding the `Contact` and `Organization` tags to all resources. This should be safe operation, but we allow disabling it via a feature flag (note that `Contact` and `Organization` tags will most likely be enforced in future `v2`).\n\n```diff\n// cdk.json\n{\n \"context\": {\n // existing context keys\n+ \"@alma-cdk/project:compatibilityV0Tags\": true\n },\n}\n```\n"
3675
+ "markdown": "<div align=\"center\">\n <h1>\n\t<img width=\"512\" src=\"assets/alma-cdk-project.svg\" alt=\"Alma CDK Project\" />\n <br/>\n <br/>\n </h1>\n\n ![Stability: Stable](https://img.shields.io/badge/stability-stable-%234BCA2A)\n ![Versioning: SemVer 2.0.0](https://img.shields.io/badge/versioning-semver_2.0.0-blue)\n [![release](https://github.com/alma-cdk/project/actions/workflows/release.yml/badge.svg)](https://github.com/alma-cdk/project/actions/workflows/release.yml)\n [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=alma-cdk_project&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=alma-cdk_project)\n [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=alma-cdk_project&metric=coverage)](https://sonarcloud.io/summary/new_code?id=alma-cdk_project)\n <hr/>\n</div>\n\n> [!Tip]\n> Migrating from `v0` to `v1`? See [Migration Guide](/docs/MIGRATION-GUIDE-0-to-1.md).\n\n<br/>\n\nOpinionated CDK “framework” with constructs & utilities for:\n- deploying multiple environments to multiple accounts (with many-to-many relationship)\n- managing account configuration through standardized props (no more random config files)\n- querying account and/or environment specific information within your CDK code\n- enabling dynamic & short-lived “feature-environments”\n- enabling well-defined tagging\n- providing structure & common conventions to CDK projects\n- choosing the target account & environment by passing in runtime context:\n\n ```sh\n npx cdk deploy -c account=dev -c environment=feature/abc-123\n ```\n ... which means you don't need to define all the possible environments ahead of time!\n\n\n\n## Account Strategies\n\nDepending on the use case, you may choose a configuration between 1-3 AWS accounts with the following environments:\n\n\n1. **Shared account (`shared`)**:\n\n ![default-multi](assets/accounts-1x.svg)\n <br/>\n\n2. **Multi-account (`dev`+`prod`)**_– RECOMMENDED_:\n\n ![default-multi](assets/accounts-2x.svg)\n <br/>\n\n<br/>\n</details>\n\n3. **Multi-account (`dev`+`preprod`+`prod`)**:\n\n ![default-multi](assets/accounts-3x.svg)\n <br/>\n\n<br/>\n\n## Getting Started\n\nSteps required to define a _environmental_ project resources; At first, it might seem complex but once you get into the habbit of defining your projects this way it starts to make sense:\n\n1. Choose your [Account Strategy](#account-strategies)\n\n2. Initialize a new `Project` instead of `cdk.App`:\n\n ```ts\n // bin/app.ts\n import { Project, AccountStrategy } from '@alma-cdk/project';\n\n const project = new Project({\n // Basic info, you could also read these from package.json if you want\n name: 'my-cool-project',\n author: {\n organization: 'Acme Corp',\n name: 'Mad Scientists',\n email: 'mad.scientists@acme.example.com',\n },\n\n // If not set, defaults to one of: $CDK_DEFAULT_REGION, $AWS_REGION or us-east-1\n defaultRegion: 'eu-west-1',\n\n // Configures the project to use 2 AWS accounts (recommended)\n accounts: AccountStrategy.two({\n dev: {\n id: '111111111111',\n config: {\n // whatever you want here as [string]: any\n baseDomain: 'example.net',\n },\n },\n prod: {\n id: '222222222222',\n config: {\n // whatever you want here as [string]: any\n baseDomain: 'example.com',\n },\n },\n }),\n })\n ```\n\n3. Define a stack which `extends SmartStack` with resources:\n ```ts\n // lib/my-stack.ts\n import { Construct } from 'constructs';\n import { StackProps, RemovalPolicy } from 'aws-cdk-lib';\n import { SmartStack, Name, UrlName, PathName, EC } from '@alma-cdk/project';\n\n export class MyStack extends SmartStack {\n constructor(scope: Construct, id: string, props: StackProps) {\n super(scope, id, props);\n\n new dynamodb.Table(this, 'Table', {\n removalPolicy: EC.isStable(this) ? RemovalPolicy.RETAIN : RemovalPolicy.DESTROY,\n\n tableName: Name.it(this, 'MyTable'),\n partitionKey: {\n type: dynamodb.AttributeType.STRING,\n name: 'pk',\n },\n // StagingMyTable\n });\n\n new events.EventBus(this, 'EventBus', {\n eventBusName: Name.withProject(this, 'MyEventBus'),\n // MyCoolProjectStagingMyEventBus\n });\n\n new s3.Bucket(this, 'Bucket', {\n\n removalPolicy: EC.isStable(this) ? RemovalPolicy.RETAIN : RemovalPolicy.DESTROY,\n autoDeleteObjects: EC.isStable(this) ? false : true,\n\n bucketName: UrlName.globally(this, 'MyBucket'),\n // acme-corp-my-cool-project-feature-foo-bar-my-bucket\n });\n\n new ssm.StringParameter(this, 'Parameter', {\n stringValue: 'Foo',\n tier: ssm.ParameterTier.ADVANCED,\n parameterName: PathName.withProject(this, 'MyNamespace/MyParameter'),\n // /MyCoolProject/Staging/MyNamespace/MyParameter\n });\n }\n }\n ```\n\n4. Define a new _environmental_ which `extends EnvironmentWrapper` and initialize all your environmental `SmartStack` stacks within:\n\n ```ts\n // lib/environment.ts\n import { Construct } from 'constructs';\n import { EnvironmentWrapper } from '@alma-cdk/project';\n import { MyStack } from './my-stack';\n\n export class Environment extends EnvironmentWrapper {\n constructor(scope: Construct) {\n super(scope);\n new MyStack(this, 'MyStack', { description: 'This is required' });\n }\n }\n ```\n\n Resulting Stack properties (given `environment=staging`):\n\n | Property | Example value |\n | :---------------------- | :--------------------------------------------------- |\n | `stackName` | `\"MyCoolProject-Environment-Staging-MyExampleStack\"` |\n | `terminationProtection` | `true` |\n | `env.account` | `\"111111111111\"` |\n | `env.region` | `\"eu-west-1\"` |\n\n Resulting Tags for the Stack and its resources (given `environment=staging`):\n\n | Property | Example value |\n | :---------------------- | :-------------------------------- |\n | `Account` | `dev` |\n | `Environment` | `staging` |\n | `Project` | `my-cool-project` |\n | `Author` | `Mad Scientists` |\n | `Organization` | `Acme Corp` |\n | `Contact` | `mad.scientists@acme.example.com` |\n\n5. Finally initialize the environment with the `Project` scope:\n\n ```ts\n // bin/app.ts\n import { Project, Accounts } from '@alma-cdk/project';\n import { Environment } from '../lib/environment';\n\n const project = new Project({/* removed for brevity, see step 1 */})\n\n new Environment(project);\n ```\n\n<br/>\n\n\n## Documentation\n\nSee detailed documentation for specific classes & methods at [constructs.dev](http://constructs.dev/packages/@alma-cdk/project).\n\nGenerally speaking you would be most interested in the following:\n- Project\n- AccountStrategy\n- SmartStack\n- AccountWrapper & EnvironmentWrapper\n- AccountContext (AC)\n- EnvironmentContext (EC)\n- Name / UrlName / PathName\n\nMigrating from `v0` to `v1`? See [Migration Guide](/docs/MIGRATION-GUIDE-0-to-1.md).\n\n<br/>\n"
3676
3676
  },
3677
3677
  "repository": {
3678
3678
  "type": "git",
@@ -6320,6 +6320,6 @@
6320
6320
  "symbolId": "src/name/name-url:UrlName"
6321
6321
  }
6322
6322
  },
6323
- "version": "1.0.1",
6324
- "fingerprint": "GlZNKsH4jo3fr9hfyXIHjroY7BBowPUTLcVJI+duxhM="
6323
+ "version": "1.0.3",
6324
+ "fingerprint": "M0w9l9SlJ4ormrurMadPumFFTwqtIq2SnP9tWnb//LQ="
6325
6325
  }
package/README.md CHANGED
@@ -1,38 +1,37 @@
1
1
  <div align="center">
2
- <br/>
3
- <br/>
4
2
  <h1>
5
- <img width="300" src="assets/alma-cdk-project.svg" alt="Alma CDK Project" />
3
+ <img width="512" src="assets/alma-cdk-project.svg" alt="Alma CDK Project" />
6
4
  <br/>
7
5
  <br/>
8
6
  </h1>
9
7
 
10
- ![NPM License](https://img.shields.io/npm/l/%40alma-cdk%2Fproject)
8
+ ![Stability: Stable](https://img.shields.io/badge/stability-stable-%234BCA2A)
9
+ ![Versioning: SemVer 2.0.0](https://img.shields.io/badge/versioning-semver_2.0.0-blue)
11
10
  [![release](https://github.com/alma-cdk/project/actions/workflows/release.yml/badge.svg)](https://github.com/alma-cdk/project/actions/workflows/release.yml)
11
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=alma-cdk_project&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=alma-cdk_project)
12
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=alma-cdk_project&metric=coverage)](https://sonarcloud.io/summary/new_code?id=alma-cdk_project)
13
+ <hr/>
14
+ </div>
12
15
 
13
- ```sh
14
- npm i -D @alma-cdk/project
15
- ```
16
+ > [!Tip]
17
+ > Migrating from `v0` to `v1`? See [Migration Guide](/docs/MIGRATION-GUIDE-0-to-1.md).
16
18
 
17
- <div align="left">
19
+ <br/>
18
20
 
19
- Opinionated CDK “framework” with constructs & utilities for:
20
- - deploying multiple environments to multiple accounts (with many-to-many relationship)
21
- - managing account configuration through standardized props (no more random config files)
22
- - querying account and/or environment specific information within your CDK code
23
- - enabling dynamic & short-lived “feature-environments”
24
- - enabling well-defined tagging
25
- - providing structure & common conventions to CDK projects
26
- - choosing the target account & environment by passing in runtime context:
21
+ Opinionated CDK “framework” with constructs & utilities for:
22
+ - deploying multiple environments to multiple accounts (with many-to-many relationship)
23
+ - managing account configuration through standardized props (no more random config files)
24
+ - querying account and/or environment specific information within your CDK code
25
+ - enabling dynamic & short-lived “feature-environments”
26
+ - enabling well-defined tagging
27
+ - providing structure & common conventions to CDK projects
28
+ - choosing the target account & environment by passing in runtime context:
27
29
 
28
- ```sh
29
- npx cdk deploy -c account=dev -c environment=feature/abc-123
30
- ```
31
- ... which means you don't need to define all the possibile environments ahead of time!
30
+ ```sh
31
+ npx cdk deploy -c account=dev -c environment=feature/abc-123
32
+ ```
33
+ ... which means you don't need to define all the possible environments ahead of time!
32
34
 
33
- </div>
34
- <br/>
35
- </div>
36
35
 
37
36
 
38
37
  ## Account Strategies
@@ -214,20 +213,6 @@ Generally speaking you would be most interested in the following:
214
213
  - EnvironmentContext (EC)
215
214
  - Name / UrlName / PathName
216
215
 
217
- ## Migration
218
-
219
- ### v0 to v1
216
+ Migrating from `v0` to `v1`? See [Migration Guide](/docs/MIGRATION-GUIDE-0-to-1.md).
220
217
 
221
- #### Tagging behavior
222
-
223
- Due to a bug in `v0`, the `Contact` and `Organization` tags were NOT applied as they should have. This means that by default, upgrading from v0→v1 introduces CloudFormation diff. Basically adding the `Contact` and `Organization` tags to all resources. This should be safe operation, but we allow disabling it via a feature flag (note that `Contact` and `Organization` tags will most likely be enforced in future `v2`).
224
-
225
- ```diff
226
- // cdk.json
227
- {
228
- "context": {
229
- // existing context keys
230
- + "@alma-cdk/project:compatibilityV0Tags": true
231
- },
232
- }
233
- ```
218
+ <br/>