๐Ÿ“ก AWS CDK 101โ›„๏ธ - API ๊ฒŒ์ดํŠธ์›จ์ด ๊ตฌ์กฐ ์‚ฌ์šฉ, ์ œํ•œ, ํ• ๋‹น๋Ÿ‰, ์‚ฌ์šฉ ๊ณ„ํš, API ํ‚ค

33219 ๋‹จ์–ด awscdkapigatewaytypescript
๐Ÿ”ฐ AWS CDK๋ฅผ ์ฒ˜์Œ ์ ‘ํ•œ ์ดˆ๋ณด์ž๋Š” ์ด ์‹œ๋ฆฌ์ฆˆ์—์„œ ์ œ ์ด์ „ ๊ธ€์„ ํ•˜๋‚˜ํ•˜๋‚˜ ์ฝ์–ด์ฃผ์„ธ์š”.
์ด์ „ ๊ธ€์„ ๋†“์น˜๋ฉด ์•„๋ž˜ ๋งํฌ๋ฅผ ํ†ตํ•ด ์ฐพ์•„๋ณด์„ธ์š”.
๐Ÿ” ์›๋ž˜๐Ÿ”— Dev Post
๐Ÿ” ์ด์ „ ๊ฒŒ์‹œ๋ฌผ ์ „๋‹ฌ๐Ÿ”—
๋ณธ๋ฌธ์—์„œ, ์œ„์—์„œ ์—ด๊ฑฐํ•œ ์ด์ „ ๊ธ€์—์„œ ๋งŒ๋“  ๊ธฐ๋ณธ lambda ํ•จ์ˆ˜ ์•ž์—์„œ API ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค.

์†”๋ฃจ์…˜์— API ๊ฒŒ์ดํŠธ์›จ์ด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ โ“
lambda๋Š”awsํ™˜๊ฒฝ์—์„œ๋งŒ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด๋Ÿฌํ•œ API ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๊ณต๊ณต HTTP ๋…ธ๋“œ๋ฅผ ๊ณต๊ฐœํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ธํ„ฐ๋„ท์ƒ์˜ ๋ชจ๋“  ์‚ฌ๋žŒ์ด HTTP ํด๋ผ์ด์–ธํŠธ๋ฅผ ํ†ตํ•ด ์ด ๋…ธ๋“œ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋˜ํ•œ ์ธ์ฆ ๊ฒ€์‚ฌ๊ฐ€ ์‹คํŒจํ•  ๊ฒฝ์šฐ API ๊ฒŒ์ดํŠธ์›จ์ด๋Š” ๋ฐฑ์—”๋“œ Lambda ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜์ง€ ์•Š๊ณ ๋„ ์ž˜๋ชป๋œ ์š”์ฒญ์„ ์ฐจ๋‹จํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.API ๊ฒŒ์ดํŠธ์›จ์ด๋Š” ์ด๋Ÿฐ ๋ฐฉ์‹์œผ๋กœ ๋น„์‹ผ ๋žŒ๋ฐ”๋‹ค ํ˜ธ์ถœ ๋น„์šฉ์„ ์ ˆ๊ฐํ•˜๊ณ  ํ•„์š”์— ๋”ฐ๋ผ ๋žŒ๋ฐ”๋‹ค ํ•จ์ˆ˜์—์„œ ์š”์ฒญ ๊ฒ€์ฆ์„ ๋งˆ์šดํŠธ ํ•ด์ œํ•  ์ˆ˜ ์žˆ๋‹ค.
ํŽธ์ง‘lib/common-event-stact.ts๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.๋ชจ๋“ˆ์„ aws-cdk-lib/aws-apigateway์—์„œ agigw๋กœ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
 // this defines an new API Gateway REST API resource backed by our "eventEntry" function.
    const eventGateway = new apigw.LambdaRestApi(this, 'EventEndpoint', {
      handler: eventEntry
    });
cdk diff๋ฅผ ์‹คํ–‰ํ•  ๋•Œ ์ƒˆ ์ž์›์— ์œ ์‚ฌํ•œ ๋กœ๊ทธ์™€ ๊ด€๋ จ๋œ IAM ์ •์ฑ… ๋ณ€๊ฒฝ์„ ๊ธฐ๋Œ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
IAM Statement Changes
โ”Œโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   โ”‚ Resource                                            โ”‚ Effect โ”‚ Action                โ”‚ Principal                                           โ”‚ Condition                                           โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ + โ”‚ ${EventEndpoint/CloudWatchRole.Arn}                 โ”‚ Allow  โ”‚ sts:AssumeRole        โ”‚ Service:apigateway.amazonaws.com                    โ”‚                                                     โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ + โ”‚ ${EventEntryHandler.Arn}                            โ”‚ Allow  โ”‚ lambda:InvokeFunction โ”‚ Service:apigateway.amazonaws.com                    โ”‚ "ArnLike": {                                        โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚   "AWS:SourceArn": "arn:${AWS::Partition}:execute-a โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ pi:${AWS::Region}:${AWS::AccountId}:${EventEndpoint โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ 82CBF40A}/${EventEndpoint/DeploymentStage.prod}/*/* โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ "                                                   โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ }                                                   โ”‚
โ”‚ + โ”‚ ${EventEntryHandler.Arn}                            โ”‚ Allow  โ”‚ lambda:InvokeFunction โ”‚ Service:apigateway.amazonaws.com                    โ”‚ "ArnLike": {                                        โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚   "AWS:SourceArn": "arn:${AWS::Partition}:execute-a โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ pi:${AWS::Region}:${AWS::AccountId}:${EventEndpoint โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ 82CBF40A}/test-invoke-stage/*/*"                    โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ }                                                   โ”‚
โ”‚ + โ”‚ ${EventEntryHandler.Arn}                            โ”‚ Allow  โ”‚ lambda:InvokeFunction โ”‚ Service:apigateway.amazonaws.com                    โ”‚ "ArnLike": {                                        โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚   "AWS:SourceArn": "arn:${AWS::Partition}:execute-a โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ pi:${AWS::Region}:${AWS::AccountId}:${EventEndpoint โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ 82CBF40A}/${EventEndpoint/DeploymentStage.prod}/*/" โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ }                                                   โ”‚
โ”‚ + โ”‚ ${EventEntryHandler.Arn}                            โ”‚ Allow  โ”‚ lambda:InvokeFunction โ”‚ Service:apigateway.amazonaws.com                    โ”‚ "ArnLike": {                                        โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚   "AWS:SourceArn": "arn:${AWS::Partition}:execute-a โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ pi:${AWS::Region}:${AWS::AccountId}:${EventEndpoint โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ 82CBF40A}/test-invoke-stage/*/"                     โ”‚
โ”‚   โ”‚                                                     โ”‚        โ”‚                       โ”‚                                                     โ”‚ }                                                   โ”‚
โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
IAM Policy Changes
โ”Œโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   โ”‚ Resource                        โ”‚ Managed Policy ARN                                                                      โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ + โ”‚ ${EventEndpoint/CloudWatchRole} โ”‚ arn:${AWS::Partition}:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs โ”‚
โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
(NOTE: There may be security-related changes not in this list. See https://github.com/aws/aws-cdk/issues/1299)

Resources
[+] AWS::ApiGateway::RestApi EventEndpoint EventEndpoint82CBF40A 
[+] AWS::IAM::Role EventEndpoint/CloudWatchRole EventEndpointCloudWatchRole4E252113 
[+] AWS::ApiGateway::Account EventEndpoint/Account EventEndpointAccount1A8CF478 
[+] AWS::ApiGateway::Deployment EventEndpoint/Deployment EventEndpointDeployment9E6BA6B96f1395a2ccbaf49542e68813f77a19e7 
[+] AWS::ApiGateway::Stage EventEndpoint/DeploymentStage.prod EventEndpointDeploymentStageprod2ED092D9 
[+] AWS::ApiGateway::Resource EventEndpoint/Default/{proxy+} EventEndpointproxyCBF9AFD2 
[+] AWS::Lambda::Permission EventEndpoint/Default/{proxy+}/ANY/ApiPermission.CommonEventStackEventEndpointB06FCC50.ANY..{proxy+} EventEndpointproxyANYApiPermissionCommonEventStackEventEndpointB06FCC50ANYproxy3F9D95E2 
[+] AWS::Lambda::Permission EventEndpoint/Default/{proxy+}/ANY/ApiPermission.Test.CommonEventStackEventEndpointB06FCC50.ANY..{proxy+} EventEndpointproxyANYApiPermissionTestCommonEventStackEventEndpointB06FCC50ANYproxy75C60637 
[+] AWS::ApiGateway::Method EventEndpoint/Default/{proxy+}/ANY EventEndpointproxyANY74421EDC 
[+] AWS::Lambda::Permission EventEndpoint/Default/ANY/ApiPermission.CommonEventStackEventEndpointB06FCC50.ANY.. EventEndpointANYApiPermissionCommonEventStackEventEndpointB06FCC50ANY7F8C8232 
[+] AWS::Lambda::Permission EventEndpoint/Default/ANY/ApiPermission.Test.CommonEventStackEventEndpointB06FCC50.ANY.. EventEndpointANYApiPermissionTestCommonEventStackEventEndpointB06FCC50ANYC6DC815A 
[+] AWS::ApiGateway::Method EventEndpoint/Default/ANY EventEndpointANY8620E9D3 

์ƒ์ˆ ํ•œ ์„ฑ๊ณผ๋ฅผ ์ด๊ฒฐํ•˜๋‹ค.๐Ÿ’ฅ
์ด์ƒ์˜ ๋‚ด์šฉ์„ ์ด๊ด„ํ•˜๊ธฐ ์œ„ํ•ด ๋ฐฑ์—”๋“œ์—์„œ ๋ฌด์Šจ ์ผ์ด ์ผ์–ด๋‚ฌ๋Š”์ง€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์•Œ์•„๋ณด๊ณ  ๋ฐœํ‘œํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
  • ์ƒˆ๋กœ์šด IAM ์ •์ฑ… CloudWatchRole์„ ๋งŒ๋“ค๊ณ  ์ด ์ •์ฑ…์ด ๋กœ๊ทธ๋ฅผapigateway์—์„œcloudwatch๋กœ ์ „์†กํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ๋ฐฐ์น˜ ๋‹จ๊ณ„prod๋Š” ์ด๋ฏธ ์„ค์น˜๋˜์–ด ์žˆ์œผ๋ฉฐ, ์šฐ๋ฆฌ๋Š” ์ œํ’ˆ ๋‹จ๊ณ„์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๊ณ  ์—ฌ๋Ÿฌ ๋‹จ๊ณ„์—์„œ ๊ณผ๋„ํ•œ ํŠน์„ฑ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ์ž์› ๊ถŒํ•œ์€ ์ž„์˜Resource ๊ฒฝ๋กœ์— ํ•„์š”ํ•œ ๊ถŒํ•œ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ์ดrestapi์˜ ์ •์ƒ ๋…ธ๋“œ์™€ ํ…Œ์ŠคํŠธ ๋…ธ๋“œ๋Š” ํƒ์š• ์ž์› ๊ฒฝ๋กœ{proxy+}๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ์ž์› ๊ถŒํ•œ์€ ์ดrestapi์˜ ์ •์ƒ์ ์ธ ๋…ธ๋“œ์™€ ํ…Œ์ŠคํŠธ ๋ณ€์ˆ˜ ๋…ธ๋“œ๋ฅผ ๊ฐ€์ง„anymethod์— ํ•„์š”ํ•œ ๊ถŒํ•œ์œผ๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค.
  • ์ƒ์ˆ ํ•œ ๊ฐœ๋…์— ๋Œ€ํ•œ ๊นŠ์€ ์ดํ•ด๋Š” ์šฐ๋ฆฌ๊ฐ€rest์˜ ์œ ์‚ฌํ•œ ๋‹จ์ ์„ ๋ฐ”ํƒ•์œผ๋กœ ํ•˜๋Š” Api๋ง์„ ์•ž์œผ๋กœ ๋”์šฑ ์ œํ•œํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋  ๊ฒƒ์ด๋‹ค.
    ์ง€๊ธˆ ์ด ๋ฐฐ์น˜๋ฅผ ์ง‘ํ–‰ํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ๊ฒ€์‚ฌํ•ฉ์‹œ๋‹ค.
    ๊ทธ ์ „์—, ์ ์ ˆํ•œ ์ •๋ณด๋ฅผ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•ด lambda์—์„œ ๋‹ค์‹œ ํ•œ ๋ฒˆ ๋ณ€๊ฒฝ์„ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
    exports.receiver = async function(event:any) {
      console.log("request:", JSON.stringify(event, undefined, 2));
      return {
        statusCode: 200,
        headers: { "Content-Type": "text/plain" },
        body: `Message Received in lambda: ${JSON.stringify(event.body)}\n`
      };
    };
    
    
    cdk deploy CommonEventStack
    
    
     โœ…  CommonEventStack
    
    โœจ  Deployment time: 57.21s
    
    Outputs:
    CommonEventStack.EventEndpointA893C53E = https://lwo***********uvhg.execute-api.ap-south-1.amazonaws.com/prod/
    Stack ARN:
    arn:aws:cloudformation:ap-south-1:575066707855:stack/CommonEventStack/93688c10-a10a-11ec-b942-0ad3136ae540
    
    โœจ  Total time: 68.43s
    

    ๐Ÿƒ ๊ถŒ๊ณก์‹œํ—˜
    ์šฐ๋ฆฌ๊ฐ€ ์ด ์ •์ง€ ๋‹จ์ ์„ ๊ฒ€์‚ฌํ•˜๊ธฐ ์œ„ํ•ด ๊ถŒ๊ณก์„ ๋งŒ๋“ค ๋•Œ, ์šฐ๋ฆฌ๊ฐ€ ๋ฌด์—‡์„ ์–ป์—ˆ๋Š”์ง€ ๋ด…์‹œ๋‹ค.curl https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/prod/
    Message Received: null
    
    
    ์—ฌ๊ธฐ์„œ, ์šฐ๋ฆฌ๋Š” ์„ฑ๊ณต์ ์œผ๋กœ lambda์— ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋ƒˆ๊ณ , ์ถœ๋ ฅ์„ ์–ป์—ˆ๋‹ค.๋น„๋ก ์šฐ๋ฆฌ๋Š” null์ด ์žˆ์ง€๋งŒ, ์™œ๋ƒํ•˜๋ฉด ์šฐ๋ฆฌ๋Š” ์ตœ์ดˆ์˜ GET ์š”์ฒญ์—์„œ ์–ด๋–ค ์‹œ์ฒด๋„ ๋ณด๋‚ด์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
    ํ˜„์žฌpost ์š”์ฒญ์—์„œ ์š”์ฒญ ์ฃผ์ฒด๋ฅผ ํ†ตํ•ด ํด๋ผ์ด์–ธํŠธ๋กœ๋ถ€ํ„ฐ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋ƒ…๋‹ˆ๋‹ค.curl -H "Content-Type: application/json" -d '{ "message": "client message"}' -X POST https://********.execute-api.ap-south-1.amazonaws.com/prod/
    Message Received in lambda: "{ \"message\": \"client message\"}"
    
    ์šฐ๋ฆฌ๋Š” ์ด๋ฏธagi ์Šค์œ„์น˜๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ์„ค์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๊ทธ๊ฒƒ์„ ๊ฒ€์‚ฌํ•˜๊ณ aws ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๊ทธ๊ฒƒ์„ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    AWS ์ฝ˜์†”์˜ API ๊ฒŒ์ดํŠธ์›จ์ดโšก


    ๋‹จ์  ๊ฒฝ๋กœ์™€ ํ—ˆ์šฉ ๋ฐฉ๋ฒ• ๊ฒ€์‚ฌโšก


    ๋ฉ”์‹œ์ง€ ํ…Œ์ŠคํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ POST ์š”์ฒญ ํ˜ธ์ถœโšก


    ์œ„์—์„œ ์ƒ์„ฑํ•œ Api ๊ฒŒ์ดํŠธ์›จ์ด ์ตœ์ ํ™”โšก
    POST ๋ฐฉ๋ฒ•๊ณผ ํŠน์ •ํ•œ ์ž์› ๊ฒฝ๋กœ์—๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋กapi ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ตœ์ ํ™”ํ•ฉ๋‹ˆ๋‹ค.

    CDK API ์ฐธ์กฐ ๋ฌธ์„œ๐Ÿผ
    ๊ทธ ์ „์— cdkapi ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.๋”ฐ๋ผ์„œ ์šฐ๋ฆฌ๋Š” ์ด๋Ÿฌํ•œ ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ์—ฐ๊ตฌํ•˜์—ฌ ๋ชจ๋“  cdk ์ฐฝ๊ณ  ์ž์› ๊ตฌ์กฐ์— ํ•„์š”ํ•œ ๋งค๊ฐœ ๋ณ€์ˆ˜์™€ ์˜ต์…˜์„ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋‹ค.
    ๋งŒ์•ฝ ์šฐ๋ฆฌ๊ฐ€ ์ด๋ฏธ ๊ฐ€์ ธ์˜จ ๊ฒƒ์„ ๊ธฐ์–ตํ•œ๋‹ค๋ฉด aws-cdk-lib/aws-apigateway ์šฐ๋ฆฌ๋Š” https://docs.aws.amazon.com/cdk/api/v2์˜ ๊ตฌ์กฐ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋ฐฐ์›Œ์•ผ ํ•œ๋‹ค
    ๊ตฌ์ฒด์ ์œผ๋กœ ๋งํ•˜๋ฉด, ์šฐ๋ฆฌ๋Š” ๋ฐ˜๋“œ์‹œ ๋‚ด๋น„๊ฒŒ์ด์…˜์„ ํ•ด์•ผ ํ•œ๋‹คhttps://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway-readme.html.์—ฌ๊ธฐ์„œ ์šฐ๋ฆฌ๋Š” apigateway ๊ตฌ์กฐ์— ํ•„์š”ํ•œ ๋ฌธ์„œ์™€ ๊ทธ ์†์„ฑ๊ณผ ๋ฐฉ๋ฒ•์„ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€, ๊ทธ๋ฆฌ๊ณ  ์ ๋‹นํ•œ ์˜ˆ์‹œ๋ฅผ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ๋‹ค.

    ์˜ฌ๋ฐ”๋ฅธ ์ž์› ๊ฒฝ๋กœ ๋ฐ ๋ฐฉ๋ฒ• ์ง€์ •๐Ÿ”ฆ
    ์šฐ์„ , ์ด ํƒ์š•์Šค๋Ÿฌ์šด ์—์ด์ „ํŠธ ์ž์› ๊ฒฝ๋กœ ์ •์˜๋ฅผ ์‚ญ์ œํ•ฉ์‹œ๋‹ค.
    const eventGateway = new apigw.LambdaRestApi(this, 'EventEndpoint', {
          handler: eventEntry,
          proxy: false
        });
    
    ์—ฌ๊ธฐ์—์„œ ํ”„๋ก์‹œ ์†์„ฑ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ํƒ์š•์Šค๋Ÿฌ์šด ์ž์› ๊ฒฝ๋กœ ์ •์˜๋ฅผ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.
    ๋‹ค์Œ ์˜ˆ์‹œ์™€ ๊ฐ™์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ž์› ๊ฒฝ๋กœ๋ฅผ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.
     const eventHandler: apigw.LambdaIntegration = new apigw.LambdaIntegration(eventEntry);
        const event = eventGateway.root.addResource('event');
    
        const eventMethod: apigw.Method = event.addMethod('POST', eventHandler, {  
           apiKeyRequired: false
        });
    

    ํ˜„์žฌ ์šฐ๋ฆฌ๋Š” ํŠน์ •ํ•œ ์ž์› ๊ฒฝ๋กœ์™€ ๋ฐฉ๋ฒ•์„ ์„ฑ๊ณต์ ์œผ๋กœ ๊ณต๊ฐœํ•˜๊ณ  ํ—ˆ์šฉํ•  ๋ฟ์ด๋‹ค.


    ๊ธˆ์ง€๋œ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ธฐ๋ณธ ์ž์› ๊ฒฝ๋กœ์— ์ ‘๊ทผํ•  ๋•Œ๐Ÿ”ฆ

    ํŠน์ •api์— ์„ฑ๊ณต์ ์œผ๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์ง€๋งŒ full path ํ—ˆ์šฉ๋œ ๋ฐฉ๋ฒ•๊ณผ ์ฐจ์ด์ ์— ์ฃผ์˜ํ•˜์‹ญ์‹œ์˜ค.


    ๊ณ„ํš ๋ฐ API ํ‚ค ์‚ฌ์šฉ๐Ÿ””

    A usage plan specifies who can access one or more deployed API stages and methods, and the rate at which they can be accessed.


    ์ด ํ”„๋กœ๊ทธ๋žจ์€ API ํ‚ค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ API ํด๋ผ์ด์–ธํŠธ๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ํ•ด๋‹น API ๋‹จ๊ณ„์— ๋Œ€ํ•œ ๊ฐ ํ‚ค์˜ ์•ก์„ธ์Šค๋ฅผ ์ ์ ˆํ•˜๊ฒŒ ์ธก์ •ํ•ฉ๋‹ˆ๋‹ค.๋˜ํ•œ ์Šค์ผ€์ค„์„ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐœ๋ณ„ ํด๋ผ์ด์–ธํŠธ API ํ‚ค์— ๋Œ€ํ•ด ๊ฐ•์ œ๋กœ ์ˆ˜ํ–‰๋˜๋Š” ์Šค๋กœํ‹€ ์ œํ•œ ๋ฐ ํ• ๋‹น๋Ÿ‰ ์ œํ•œ๋„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    ๋‹ค์Œ ์˜ˆ์ œ์—์„œ๋Š” ์‚ฌ์šฉ ๊ณ„ํš ๋ฐ API ํ‚ค๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ์—ฐ๊ด€์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ ์ค๋‹ˆ๋‹ค.
    const eventMethod: apigw.Method = event.addMethod('POST', eventHandler, {  
           apiKeyRequired: true,
        });
    

    In order to use a api key it is required to setup an usage plan, something similar to the below example and then we can associate that to the key we just created.


    
    const plan = eventGateway.addUsagePlan('UsagePlan', {
            name: 'Workshop',
            description: 'For Workshop',
            throttle: {
              burstLimit: 5,
              rateLimit: 10,
            },
            quota: {
              limit: 100,
              period: apigw.Period.DAY
            }
        });
    
        const normalUserKey = eventGateway.addApiKey('ApiKey',{
            apiKeyName: 'av-api-key',
            value: 'av-api-key-value-********',
        });
        plan.addApiKey(normalUserKey);
    


    ๋ฐฐํฌ ๋‹จ๊ณ„๋ณ„ ๋ฏธ์„ธ ์กฐ์ • ์‚ฌ์šฉ ๊ณ„ํš๐ŸŒป
    ํŠน์ • ๋ฐฉ๋ฒ•์˜ ์„œ๋กœ ๋‹ค๋ฅธ ๋ฐฐ์น˜ ๋‹จ๊ณ„์—์„œ ์ƒ์ˆ ํ•œ ์‚ฌ์šฉ ๊ณ„ํš์„ ๋ฏธ์„ธํ•˜๊ฒŒ ์กฐ์ •ํ•œ๋‹ค. ๋˜ํ•œ ๋ฐฉ๋ฒ• ๋‹จ๊ณ„์˜ ์ ˆ์•ฝ ์ œํ•œ์„ ํฌํ•จํ•˜์—ฌapi ์†Œ๋ชจ ์ œํ•œ์„ ๋”์šฑ ์ž˜ ํ†ต์ œํ•˜๊ณ  ๊ณ„์•ฝ์— ๋”ฐ๋ผ ์—ฌ๋Ÿฌ ๊ณ ๊ฐ์˜ ์ž์› ์ด์šฉ๋ฅ ์„ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค.
     plan.addApiStage({
          stage: eventGateway.deploymentStage,
          throttle: [
            {
              method: eventMethod,
              throttle: {
                rateLimit: 3,
                burstLimit: 2
              }
            }
          ]
        });
    

    ์†๋„์™€ ๋Œ๋ฐœ ์ œํ•œ์„ ์‚ฌ์šฉํ•˜์—ฌapi๋ฅผ ์ œํ•œํ•ฉ๋‹ˆ๋‹ค๐Ÿ‡
    ๊ฒŒ์ดํŠธ์›จ์ด๊ฐ€ ์ž…๊ตฌ ์ž์ฒด์˜ ์ถ”๊ฐ€ ์š”์ฒญ์„ ๊ฑฐ๋ถ€ํ•˜๊ธฐ ์ „์—, ๋‹น์‹ ์€ ์†๋„ ์ œํ•œ์„ ํ†ตํ•ด ์ดˆ๋‹น ํ˜ธ์ถœ ํšŸ์ˆ˜์˜ ์†๋„๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ์ œ์–ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • API๊ฐ€ ๋™์‹œ์— ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ์š”์ฒญ ์ˆ˜๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
  • ์†๋„ ์ œํ•œ์€ ์ดˆ๋‹น ํ—ˆ์šฉ๋˜๋Š” ์š”์ฒญ ์ˆ˜๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
  •  throttle: {
                rateLimit: 3,
                burstLimit: 2
              }
    


    ํ• ๋‹น๋Ÿ‰ ์ œํ•œ๐Ÿก
    ํ• ๋‹น์•ก ์ œํ•œ์€api์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์ธํ„ฐํŽ˜์ด์Šค ์ œํ•œ์„ ์ดˆ๊ณผํ•˜๊ธฐ ์ „์— ๋ฐ›์€ ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ์˜ ๋ˆ„์  ์ˆ˜๋Ÿ‰์„ ์ •์˜ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋œ๋‹ค.
    ๋ณดํ†ตaws๋Š” ๊ฐ ์ง€์—ญ์˜ ๋ชจ๋“  ์„œ๋น„์Šค์— ์ผ์ •ํ•œ ๊ณ ์ • ํ• ๋‹น์•ก์„ ์ œ๊ณตํ•˜๋Š”๋ฐ ์ด๊ฒƒ์€ ์ˆ˜์š”์— ๋”ฐ๋ผ ๋ชจ๋“  ์‚ฌ์šฉ ๊ณ„ํš์˜ ์ผ๋ถ€๋ถ„์„ ๋ณด์กดํ•จ์œผ๋กœ์จ ํšจ๊ณผ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.์™ธ๋ถ€ ์‚ฌ์šฉ์žapi์˜ ์‚ฌ์šฉ์„ ์ œํ•œํ•˜๊ธฐ ์œ„ํ•ด ์™ธ๋ถ€ ์‚ฌ์šฉ์ž์˜ ์„œ๋น„์Šค ์ธต์— ๋”ฐ๋ผ ๊ฒ€์‚ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
     quota: {
          limit: 5,
          period: apigw.Period.DAY
          }
    
    api ํ‚ค ์‚ฌ์šฉ์ž์—๊ฒŒ ํ• ๋‹น๋œ ํ• ๋‹น๋Ÿ‰์„ ์ดˆ๊ณผํ•˜๋ฉด ์˜ค๋ฅ˜ ์‘๋‹ต์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.



    ์†๋„ ์ œํ•œ API ํ‚ค๐Ÿ 
    ๋‹จ์ผapi ํ‚ค๋ฅผ ๋งŒ๋“ค๊ณ  ์†๋„ ์ œํ•œ์„ ์„ค์ •ํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ RateLimitedApiKey ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.์ด ๊ตฌ์กฐ๋Š” ์†๋„ ์ œํ•œ ์†์„ฑ์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์†์„ฑ๋“ค์€ ๋งŒ๋“ค๊ณ  ์žˆ๋Š”api ํ‚ค์—๋งŒ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.์ƒ์„ฑ๋œ API ํ‚ค์—๋Š” ํ• ๋‹น๋Ÿ‰ ๋ฐ ์ œํ•œ ๋“ฑ ์ง€์ •๋œ ์†๋„ ์ œํ•œ์ด ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.
    const rateLimitedKey = new apigw.RateLimitedApiKey(this, 'rate-limited-api-key', {
           apiKeyName: 'av-rate-limited-api-key',
            value: 'av-api-key-value-dreatenbwebrwiukjwnrn',
        customerId: 'external-client',
        resources: [eventGateway],
        quota: {
          limit: 5,
          period: apigw.Period.DAY
          },
          throttle: {
            rateLimit: 2,
            burstLimit: 1
          }
        });
        plan.addApiKey(rateLimitedKey);
    
    ์ƒˆ๋กœ ๋งŒ๋“ api ํ‚ค๋ฅผ ์œ„ํ•œ ์ƒˆ๋กœ์šด ๊ณ„ํš์„ ์ฐพ์„ ์ˆ˜ ์žˆ๋„๋กapi ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๊ฒ€์‚ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.๋‹ค๋ฅธ ์‚ฌ์šฉ ๊ณ„ํš์— ์†ํ•˜์ง€ ์•Š๋Š” ๊ฐœ๋ณ„ ์‚ฌ์šฉ์ž๋ฅผ ๋”์šฑ ์„ธ๋ฐ€ํ•˜๊ฒŒ ์ œ์–ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



    ๊ธฐ์กด ํ‚ค ๋ฐ ์‚ฌ์šฉ ๊ณ„ํš ๊ฐ€์ ธ์˜ค๊ธฐ๐Ÿ
    ์ด์™ธ์—, ์šฐ๋ฆฌ๋Š” ์•„๋ž˜์˜ ์˜ˆ์‹œ๋ฅผ ํ†ตํ•ด ๊ธฐ์กด ํ‚ค์™€ ์‚ฌ์šฉ ๊ณ„ํš์„ ์šฐ๋ฆฌ์˜ ์ฐฝ๊ณ  ์ž์›์— ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    usage plans can be imported into a CDK app using its id.


    const importedUsagePlan = apigateway.UsagePlan.fromUsagePlanId(this, 'imported-usage-plan', '<usage-plan-key-id>');
    

    API keys can also be imported into a CDK app using its id.


    const importedKey = apigateway.ApiKey.fromApiKeyId(this, 'imported-key', '<api-key-id>');
    
    ์ดapi ์ธํ„ฐํŽ˜์ด์Šค์™€ lambda์— ๋” ๋งŽ์€ ์—ฐ๊ฒฐ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ๋‹ค์Œ ๊ธ€์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
    โญ ์šฐ๋ฆฌ์˜ ๋‹ค์Œ ๊ธ€์€ ์„œ๋ฒ„less์— ๋ฐœํ‘œ๋  ๊ฒƒ์ด๋‹ˆ, ๋ฐ˜๋“œ์‹œ ๋ณด์‹ญ์‹œ์˜ค
    ๐ŸŽ‰ ์ง€์ง€ํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!๐Ÿ™
    ๋งŒ์•ฝ ๋„ค๊ฐ€ โ˜• Buy Me a Coffee๋‚˜๋ฅผ ๋•๊ธฐ๋ฅผ ์›ํ•œ๋‹ค๋ฉด, ์ •๋ง ์ข‹๊ฒ ๋‹ค.
    ๐Ÿ” ์›๋ž˜๐Ÿ”— Dev Post
    ๐Ÿ” ์ „์žฌํ•˜๋‹ค๐Ÿ”—

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ