0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AWS CDK Study-3 ~共通タグの付与~

Posted at

チームや組織のルールで 「全リソースに同じタグを付与する」 のようなことがあると思います。現在所属している開発チームもcdkで構築したリソースに共通タグをつけるルールがあります。
とはいえ、個々のリソースにちまちまとタグをつけるのはめんどくさい大変なので、一括で付与する方法を探してみたところ、ありましたので、残しておきます。

環境

% sw_vers
ProductName:		macOS
ProductVersion:		14.7.3
BuildVersion:		23H417
% aws --version
aws-cli/2.9.10 Python/3.9.11 Darwin/23.6.0 exe/x86_64 prompt/off
% cdk --version
2.178.2 (build 89c49cc)
% npm --version
11.1.0
% node --version
v20.17.0

一括で共通タグを付与

bin/infrastructure.ts
#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';
import { TestStack } from '../lib/test-stack';

const tagKey: string = 'foo';
const tagValue: string = 'bar';

const app = new cdk.App();

const testStackId: string = 'sample-test-stack';
const testStack = new TestStack(app, testStackId);

// 一括で共通タグを付与
cdk.Tags.of(app).add(tagKey, tagValue);

// Stack毎に共通タグを付与する場合
cdk.Tags.of(testStack).add(tagKey, tagValue);

Next

API Gateway+Lambdaを構築する予定です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?