@epilot360/icons 0.0.1 → 0.0.2

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.
Files changed (459) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/bundle.js +2 -0
  4. package/dist/bundle.js.map +1 -0
  5. package/iac/node_modules/@balena/dockerignore/LICENSE.md +206 -0
  6. package/iac/node_modules/@balena/dockerignore/README.md +261 -0
  7. package/iac/node_modules/@cspotcode/source-map-support/LICENSE.md +21 -0
  8. package/iac/node_modules/@cspotcode/source-map-support/README.md +289 -0
  9. package/iac/node_modules/@jridgewell/resolve-uri/LICENSE +19 -0
  10. package/iac/node_modules/@jridgewell/resolve-uri/README.md +40 -0
  11. package/iac/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map +1 -0
  12. package/iac/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map +1 -0
  13. package/iac/node_modules/@jridgewell/sourcemap-codec/LICENSE +21 -0
  14. package/iac/node_modules/@jridgewell/sourcemap-codec/README.md +200 -0
  15. package/iac/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  16. package/iac/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +1 -0
  17. package/iac/node_modules/@jridgewell/trace-mapping/LICENSE +19 -0
  18. package/iac/node_modules/@jridgewell/trace-mapping/README.md +193 -0
  19. package/iac/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map +1 -0
  20. package/iac/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map +1 -0
  21. package/iac/node_modules/@tsconfig/node10/LICENSE +21 -0
  22. package/iac/node_modules/@tsconfig/node10/README.md +40 -0
  23. package/iac/node_modules/@tsconfig/node12/LICENSE +21 -0
  24. package/iac/node_modules/@tsconfig/node12/README.md +40 -0
  25. package/iac/node_modules/@tsconfig/node14/LICENSE +21 -0
  26. package/iac/node_modules/@tsconfig/node14/README.md +40 -0
  27. package/iac/node_modules/@tsconfig/node16/LICENSE +21 -0
  28. package/iac/node_modules/@tsconfig/node16/README.md +40 -0
  29. package/iac/node_modules/@types/jest/LICENSE +21 -0
  30. package/iac/node_modules/@types/jest/README.md +17 -0
  31. package/iac/node_modules/@types/node/LICENSE +21 -0
  32. package/iac/node_modules/@types/node/README.md +16 -0
  33. package/iac/node_modules/@types/prettier/LICENSE +21 -0
  34. package/iac/node_modules/@types/prettier/README.md +16 -0
  35. package/iac/node_modules/acorn/LICENSE +21 -0
  36. package/iac/node_modules/acorn/README.md +273 -0
  37. package/iac/node_modules/acorn-walk/LICENSE +21 -0
  38. package/iac/node_modules/acorn-walk/README.md +126 -0
  39. package/iac/node_modules/ansi-regex/license +9 -0
  40. package/iac/node_modules/ansi-regex/readme.md +78 -0
  41. package/iac/node_modules/ansi-styles/license +9 -0
  42. package/iac/node_modules/ansi-styles/readme.md +144 -0
  43. package/iac/node_modules/arg/LICENSE.md +21 -0
  44. package/iac/node_modules/arg/README.md +280 -0
  45. package/iac/node_modules/at-least-node/LICENSE +6 -0
  46. package/iac/node_modules/at-least-node/README.md +25 -0
  47. package/iac/node_modules/aws-cdk/LICENSE +201 -0
  48. package/iac/node_modules/aws-cdk/README.md +742 -0
  49. package/iac/node_modules/aws-cdk/lib/init-templates/LICENSE +16 -0
  50. package/iac/node_modules/aws-cdk/lib/init-templates/app/csharp/README.md +14 -0
  51. package/iac/node_modules/aws-cdk/lib/init-templates/app/fsharp/README.md +18 -0
  52. package/iac/node_modules/aws-cdk/lib/init-templates/app/go/README.md +12 -0
  53. package/iac/node_modules/aws-cdk/lib/init-templates/app/java/README.md +18 -0
  54. package/iac/node_modules/aws-cdk/lib/init-templates/app/javascript/README.md +12 -0
  55. package/iac/node_modules/aws-cdk/lib/init-templates/app/python/README.template.md +58 -0
  56. package/iac/node_modules/aws-cdk/lib/init-templates/app/typescript/README.md +14 -0
  57. package/iac/node_modules/aws-cdk/lib/init-templates/lib/typescript/README.template.md +12 -0
  58. package/iac/node_modules/aws-cdk/lib/init-templates/sample-app/csharp/README.template.md +19 -0
  59. package/iac/node_modules/aws-cdk/lib/init-templates/sample-app/fsharp/README.template.md +20 -0
  60. package/iac/node_modules/aws-cdk/lib/init-templates/sample-app/go/README.md +12 -0
  61. package/iac/node_modules/aws-cdk/lib/init-templates/sample-app/java/README.template.md +19 -0
  62. package/iac/node_modules/aws-cdk/lib/init-templates/sample-app/javascript/README.template.md +13 -0
  63. package/iac/node_modules/aws-cdk/lib/init-templates/sample-app/python/README.template.md +65 -0
  64. package/iac/node_modules/aws-cdk/lib/init-templates/sample-app/typescript/README.template.md +15 -0
  65. package/iac/node_modules/aws-cdk/test/integ/cli/README.md +48 -0
  66. package/iac/node_modules/aws-cdk/test/integ/cli-regression-patches/README.md +54 -0
  67. package/iac/node_modules/aws-cdk-lib/LICENSE +201 -0
  68. package/iac/node_modules/aws-cdk-lib/README.md +1119 -0
  69. package/iac/node_modules/aws-cdk-lib/alexa-ask/README.md +27 -0
  70. package/iac/node_modules/aws-cdk-lib/assertions/README.md +571 -0
  71. package/iac/node_modules/aws-cdk-lib/assets/README.md +4 -0
  72. package/iac/node_modules/aws-cdk-lib/aws-accessanalyzer/README.md +27 -0
  73. package/iac/node_modules/aws-cdk-lib/aws-acmpca/README.md +59 -0
  74. package/iac/node_modules/aws-cdk-lib/aws-amazonmq/README.md +27 -0
  75. package/iac/node_modules/aws-cdk-lib/aws-amplify/README.md +32 -0
  76. package/iac/node_modules/aws-cdk-lib/aws-amplifyuibuilder/README.md +27 -0
  77. package/iac/node_modules/aws-cdk-lib/aws-apigateway/README.md +1335 -0
  78. package/iac/node_modules/aws-cdk-lib/aws-apigatewayv2/README.md +32 -0
  79. package/iac/node_modules/aws-cdk-lib/aws-appconfig/README.md +27 -0
  80. package/iac/node_modules/aws-cdk-lib/aws-appflow/README.md +27 -0
  81. package/iac/node_modules/aws-cdk-lib/aws-appintegrations/README.md +27 -0
  82. package/iac/node_modules/aws-cdk-lib/aws-applicationautoscaling/README.md +246 -0
  83. package/iac/node_modules/aws-cdk-lib/aws-applicationinsights/README.md +27 -0
  84. package/iac/node_modules/aws-cdk-lib/aws-appmesh/README.md +883 -0
  85. package/iac/node_modules/aws-cdk-lib/aws-apprunner/README.md +32 -0
  86. package/iac/node_modules/aws-cdk-lib/aws-appstream/README.md +27 -0
  87. package/iac/node_modules/aws-cdk-lib/aws-appsync/README.md +32 -0
  88. package/iac/node_modules/aws-cdk-lib/aws-aps/README.md +27 -0
  89. package/iac/node_modules/aws-cdk-lib/aws-athena/README.md +27 -0
  90. package/iac/node_modules/aws-cdk-lib/aws-auditmanager/README.md +27 -0
  91. package/iac/node_modules/aws-cdk-lib/aws-autoscaling/README.md +540 -0
  92. package/iac/node_modules/aws-cdk-lib/aws-autoscaling-common/README.md +8 -0
  93. package/iac/node_modules/aws-cdk-lib/aws-autoscaling-hooktargets/README.md +18 -0
  94. package/iac/node_modules/aws-cdk-lib/aws-autoscalingplans/README.md +27 -0
  95. package/iac/node_modules/aws-cdk-lib/aws-backup/README.md +210 -0
  96. package/iac/node_modules/aws-cdk-lib/aws-batch/README.md +32 -0
  97. package/iac/node_modules/aws-cdk-lib/aws-billingconductor/README.md +27 -0
  98. package/iac/node_modules/aws-cdk-lib/aws-budgets/README.md +27 -0
  99. package/iac/node_modules/aws-cdk-lib/aws-cassandra/README.md +27 -0
  100. package/iac/node_modules/aws-cdk-lib/aws-ce/README.md +27 -0
  101. package/iac/node_modules/aws-cdk-lib/aws-certificatemanager/README.md +166 -0
  102. package/iac/node_modules/aws-cdk-lib/aws-certificatemanager/lambda-packages/dns_validated_certificate_handler/README.md +2 -0
  103. package/iac/node_modules/aws-cdk-lib/aws-certificatemanager/suffixes/README.txt +8 -0
  104. package/iac/node_modules/aws-cdk-lib/aws-chatbot/README.md +44 -0
  105. package/iac/node_modules/aws-cdk-lib/aws-cloud9/README.md +32 -0
  106. package/iac/node_modules/aws-cdk-lib/aws-cloudformation/README.md +4 -0
  107. package/iac/node_modules/aws-cdk-lib/aws-cloudfront/README.md +973 -0
  108. package/iac/node_modules/aws-cdk-lib/aws-cloudfront-origins/README.md +126 -0
  109. package/iac/node_modules/aws-cdk-lib/aws-cloudtrail/README.md +189 -0
  110. package/iac/node_modules/aws-cdk-lib/aws-cloudwatch/README.md +579 -0
  111. package/iac/node_modules/aws-cdk-lib/aws-cloudwatch-actions/README.md +43 -0
  112. package/iac/node_modules/aws-cdk-lib/aws-codeartifact/README.md +27 -0
  113. package/iac/node_modules/aws-cdk-lib/aws-codebuild/README.md +759 -0
  114. package/iac/node_modules/aws-cdk-lib/aws-codecommit/README.md +85 -0
  115. package/iac/node_modules/aws-cdk-lib/aws-codedeploy/README.md +319 -0
  116. package/iac/node_modules/aws-cdk-lib/aws-codeguruprofiler/README.md +37 -0
  117. package/iac/node_modules/aws-cdk-lib/aws-codegurureviewer/README.md +27 -0
  118. package/iac/node_modules/aws-cdk-lib/aws-codepipeline/README.md +481 -0
  119. package/iac/node_modules/aws-cdk-lib/aws-codepipeline-actions/README.md +1203 -0
  120. package/iac/node_modules/aws-cdk-lib/aws-codestar/README.md +32 -0
  121. package/iac/node_modules/aws-cdk-lib/aws-codestarconnections/README.md +27 -0
  122. package/iac/node_modules/aws-cdk-lib/aws-codestarnotifications/README.md +68 -0
  123. package/iac/node_modules/aws-cdk-lib/aws-cognito/README.md +843 -0
  124. package/iac/node_modules/aws-cdk-lib/aws-config/README.md +218 -0
  125. package/iac/node_modules/aws-cdk-lib/aws-connect/README.md +27 -0
  126. package/iac/node_modules/aws-cdk-lib/aws-controltower/README.md +27 -0
  127. package/iac/node_modules/aws-cdk-lib/aws-cur/README.md +27 -0
  128. package/iac/node_modules/aws-cdk-lib/aws-customerprofiles/README.md +27 -0
  129. package/iac/node_modules/aws-cdk-lib/aws-databrew/README.md +27 -0
  130. package/iac/node_modules/aws-cdk-lib/aws-datapipeline/README.md +27 -0
  131. package/iac/node_modules/aws-cdk-lib/aws-datasync/README.md +27 -0
  132. package/iac/node_modules/aws-cdk-lib/aws-dax/README.md +27 -0
  133. package/iac/node_modules/aws-cdk-lib/aws-detective/README.md +27 -0
  134. package/iac/node_modules/aws-cdk-lib/aws-devopsguru/README.md +27 -0
  135. package/iac/node_modules/aws-cdk-lib/aws-directoryservice/README.md +27 -0
  136. package/iac/node_modules/aws-cdk-lib/aws-dlm/README.md +27 -0
  137. package/iac/node_modules/aws-cdk-lib/aws-dms/README.md +27 -0
  138. package/iac/node_modules/aws-cdk-lib/aws-docdb/README.md +153 -0
  139. package/iac/node_modules/aws-cdk-lib/aws-dynamodb/README.md +200 -0
  140. package/iac/node_modules/aws-cdk-lib/aws-ec2/README.md +1514 -0
  141. package/iac/node_modules/aws-cdk-lib/aws-ecr/README.md +110 -0
  142. package/iac/node_modules/aws-cdk-lib/aws-ecr-assets/README.md +167 -0
  143. package/iac/node_modules/aws-cdk-lib/aws-ecs/README.md +1225 -0
  144. package/iac/node_modules/aws-cdk-lib/aws-ecs-patterns/README.md +980 -0
  145. package/iac/node_modules/aws-cdk-lib/aws-efs/README.md +154 -0
  146. package/iac/node_modules/aws-cdk-lib/aws-eks/README.md +1450 -0
  147. package/iac/node_modules/aws-cdk-lib/aws-elasticache/README.md +27 -0
  148. package/iac/node_modules/aws-cdk-lib/aws-elasticbeanstalk/README.md +27 -0
  149. package/iac/node_modules/aws-cdk-lib/aws-elasticloadbalancing/README.md +40 -0
  150. package/iac/node_modules/aws-cdk-lib/aws-elasticloadbalancingv2/README.md +569 -0
  151. package/iac/node_modules/aws-cdk-lib/aws-elasticloadbalancingv2-actions/README.md +68 -0
  152. package/iac/node_modules/aws-cdk-lib/aws-elasticloadbalancingv2-targets/README.md +4 -0
  153. package/iac/node_modules/aws-cdk-lib/aws-elasticsearch/README.md +441 -0
  154. package/iac/node_modules/aws-cdk-lib/aws-emr/README.md +27 -0
  155. package/iac/node_modules/aws-cdk-lib/aws-emrcontainers/README.md +27 -0
  156. package/iac/node_modules/aws-cdk-lib/aws-emrserverless/README.md +27 -0
  157. package/iac/node_modules/aws-cdk-lib/aws-events/README.md +249 -0
  158. package/iac/node_modules/aws-cdk-lib/aws-events-targets/README.md +339 -0
  159. package/iac/node_modules/aws-cdk-lib/aws-eventschemas/README.md +27 -0
  160. package/iac/node_modules/aws-cdk-lib/aws-evidently/README.md +27 -0
  161. package/iac/node_modules/aws-cdk-lib/aws-finspace/README.md +27 -0
  162. package/iac/node_modules/aws-cdk-lib/aws-fis/README.md +27 -0
  163. package/iac/node_modules/aws-cdk-lib/aws-fms/README.md +27 -0
  164. package/iac/node_modules/aws-cdk-lib/aws-forecast/README.md +27 -0
  165. package/iac/node_modules/aws-cdk-lib/aws-frauddetector/README.md +27 -0
  166. package/iac/node_modules/aws-cdk-lib/aws-fsx/README.md +200 -0
  167. package/iac/node_modules/aws-cdk-lib/aws-gamelift/README.md +27 -0
  168. package/iac/node_modules/aws-cdk-lib/aws-globalaccelerator/README.md +182 -0
  169. package/iac/node_modules/aws-cdk-lib/aws-globalaccelerator-endpoints/README.md +10 -0
  170. package/iac/node_modules/aws-cdk-lib/aws-glue/README.md +32 -0
  171. package/iac/node_modules/aws-cdk-lib/aws-greengrass/README.md +27 -0
  172. package/iac/node_modules/aws-cdk-lib/aws-greengrassv2/README.md +27 -0
  173. package/iac/node_modules/aws-cdk-lib/aws-groundstation/README.md +27 -0
  174. package/iac/node_modules/aws-cdk-lib/aws-guardduty/README.md +27 -0
  175. package/iac/node_modules/aws-cdk-lib/aws-healthlake/README.md +27 -0
  176. package/iac/node_modules/aws-cdk-lib/aws-iam/README.md +509 -0
  177. package/iac/node_modules/aws-cdk-lib/aws-imagebuilder/README.md +27 -0
  178. package/iac/node_modules/aws-cdk-lib/aws-inspector/README.md +27 -0
  179. package/iac/node_modules/aws-cdk-lib/aws-inspectorv2/README.md +27 -0
  180. package/iac/node_modules/aws-cdk-lib/aws-iot/README.md +32 -0
  181. package/iac/node_modules/aws-cdk-lib/aws-iot1click/README.md +27 -0
  182. package/iac/node_modules/aws-cdk-lib/aws-iotanalytics/README.md +27 -0
  183. package/iac/node_modules/aws-cdk-lib/aws-iotcoredeviceadvisor/README.md +27 -0
  184. package/iac/node_modules/aws-cdk-lib/aws-iotevents/README.md +32 -0
  185. package/iac/node_modules/aws-cdk-lib/aws-iotfleethub/README.md +27 -0
  186. package/iac/node_modules/aws-cdk-lib/aws-iotsitewise/README.md +27 -0
  187. package/iac/node_modules/aws-cdk-lib/aws-iotthingsgraph/README.md +27 -0
  188. package/iac/node_modules/aws-cdk-lib/aws-iottwinmaker/README.md +27 -0
  189. package/iac/node_modules/aws-cdk-lib/aws-iotwireless/README.md +27 -0
  190. package/iac/node_modules/aws-cdk-lib/aws-ivs/README.md +32 -0
  191. package/iac/node_modules/aws-cdk-lib/aws-kafkaconnect/README.md +27 -0
  192. package/iac/node_modules/aws-cdk-lib/aws-kendra/README.md +27 -0
  193. package/iac/node_modules/aws-cdk-lib/aws-kinesis/README.md +188 -0
  194. package/iac/node_modules/aws-cdk-lib/aws-kinesisanalytics/README.md +27 -0
  195. package/iac/node_modules/aws-cdk-lib/aws-kinesisanalyticsv2/README.md +27 -0
  196. package/iac/node_modules/aws-cdk-lib/aws-kinesisfirehose/README.md +32 -0
  197. package/iac/node_modules/aws-cdk-lib/aws-kinesisvideo/README.md +27 -0
  198. package/iac/node_modules/aws-cdk-lib/aws-kms/README.md +209 -0
  199. package/iac/node_modules/aws-cdk-lib/aws-lakeformation/README.md +27 -0
  200. package/iac/node_modules/aws-cdk-lib/aws-lambda/README.md +985 -0
  201. package/iac/node_modules/aws-cdk-lib/aws-lambda-destinations/README.md +147 -0
  202. package/iac/node_modules/aws-cdk-lib/aws-lambda-event-sources/README.md +281 -0
  203. package/iac/node_modules/aws-cdk-lib/aws-lambda-nodejs/README.md +317 -0
  204. package/iac/node_modules/aws-cdk-lib/aws-lex/README.md +27 -0
  205. package/iac/node_modules/aws-cdk-lib/aws-licensemanager/README.md +27 -0
  206. package/iac/node_modules/aws-cdk-lib/aws-lightsail/README.md +27 -0
  207. package/iac/node_modules/aws-cdk-lib/aws-location/README.md +27 -0
  208. package/iac/node_modules/aws-cdk-lib/aws-logs/README.md +322 -0
  209. package/iac/node_modules/aws-cdk-lib/aws-logs-destinations/README.md +7 -0
  210. package/iac/node_modules/aws-cdk-lib/aws-lookoutequipment/README.md +27 -0
  211. package/iac/node_modules/aws-cdk-lib/aws-lookoutmetrics/README.md +27 -0
  212. package/iac/node_modules/aws-cdk-lib/aws-lookoutvision/README.md +27 -0
  213. package/iac/node_modules/aws-cdk-lib/aws-m2/README.md +27 -0
  214. package/iac/node_modules/aws-cdk-lib/aws-macie/README.md +27 -0
  215. package/iac/node_modules/aws-cdk-lib/aws-managedblockchain/README.md +27 -0
  216. package/iac/node_modules/aws-cdk-lib/aws-mediaconnect/README.md +27 -0
  217. package/iac/node_modules/aws-cdk-lib/aws-mediaconvert/README.md +27 -0
  218. package/iac/node_modules/aws-cdk-lib/aws-medialive/README.md +27 -0
  219. package/iac/node_modules/aws-cdk-lib/aws-mediapackage/README.md +27 -0
  220. package/iac/node_modules/aws-cdk-lib/aws-mediastore/README.md +27 -0
  221. package/iac/node_modules/aws-cdk-lib/aws-mediatailor/README.md +27 -0
  222. package/iac/node_modules/aws-cdk-lib/aws-memorydb/README.md +27 -0
  223. package/iac/node_modules/aws-cdk-lib/aws-msk/README.md +32 -0
  224. package/iac/node_modules/aws-cdk-lib/aws-mwaa/README.md +27 -0
  225. package/iac/node_modules/aws-cdk-lib/aws-neptune/README.md +32 -0
  226. package/iac/node_modules/aws-cdk-lib/aws-networkfirewall/README.md +27 -0
  227. package/iac/node_modules/aws-cdk-lib/aws-networkmanager/README.md +27 -0
  228. package/iac/node_modules/aws-cdk-lib/aws-nimblestudio/README.md +27 -0
  229. package/iac/node_modules/aws-cdk-lib/aws-opensearchservice/README.md +378 -0
  230. package/iac/node_modules/aws-cdk-lib/aws-opsworks/README.md +27 -0
  231. package/iac/node_modules/aws-cdk-lib/aws-opsworkscm/README.md +27 -0
  232. package/iac/node_modules/aws-cdk-lib/aws-panorama/README.md +27 -0
  233. package/iac/node_modules/aws-cdk-lib/aws-personalize/README.md +27 -0
  234. package/iac/node_modules/aws-cdk-lib/aws-pinpoint/README.md +27 -0
  235. package/iac/node_modules/aws-cdk-lib/aws-pinpointemail/README.md +27 -0
  236. package/iac/node_modules/aws-cdk-lib/aws-qldb/README.md +27 -0
  237. package/iac/node_modules/aws-cdk-lib/aws-quicksight/README.md +27 -0
  238. package/iac/node_modules/aws-cdk-lib/aws-ram/README.md +27 -0
  239. package/iac/node_modules/aws-cdk-lib/aws-rds/README.md +704 -0
  240. package/iac/node_modules/aws-cdk-lib/aws-redshift/README.md +32 -0
  241. package/iac/node_modules/aws-cdk-lib/aws-redshiftserverless/README.md +27 -0
  242. package/iac/node_modules/aws-cdk-lib/aws-refactorspaces/README.md +27 -0
  243. package/iac/node_modules/aws-cdk-lib/aws-rekognition/README.md +27 -0
  244. package/iac/node_modules/aws-cdk-lib/aws-resiliencehub/README.md +27 -0
  245. package/iac/node_modules/aws-cdk-lib/aws-resourcegroups/README.md +27 -0
  246. package/iac/node_modules/aws-cdk-lib/aws-robomaker/README.md +27 -0
  247. package/iac/node_modules/aws-cdk-lib/aws-route53/README.md +281 -0
  248. package/iac/node_modules/aws-cdk-lib/aws-route53-patterns/README.md +45 -0
  249. package/iac/node_modules/aws-cdk-lib/aws-route53-targets/README.md +181 -0
  250. package/iac/node_modules/aws-cdk-lib/aws-route53recoverycontrol/README.md +27 -0
  251. package/iac/node_modules/aws-cdk-lib/aws-route53recoveryreadiness/README.md +27 -0
  252. package/iac/node_modules/aws-cdk-lib/aws-route53resolver/README.md +32 -0
  253. package/iac/node_modules/aws-cdk-lib/aws-rum/README.md +27 -0
  254. package/iac/node_modules/aws-cdk-lib/aws-s3/README.md +581 -0
  255. package/iac/node_modules/aws-cdk-lib/aws-s3-assets/README.md +179 -0
  256. package/iac/node_modules/aws-cdk-lib/aws-s3-deployment/README.md +349 -0
  257. package/iac/node_modules/aws-cdk-lib/aws-s3-notifications/README.md +46 -0
  258. package/iac/node_modules/aws-cdk-lib/aws-s3objectlambda/README.md +32 -0
  259. package/iac/node_modules/aws-cdk-lib/aws-s3outposts/README.md +27 -0
  260. package/iac/node_modules/aws-cdk-lib/aws-sagemaker/README.md +27 -0
  261. package/iac/node_modules/aws-cdk-lib/aws-sam/README.md +27 -0
  262. package/iac/node_modules/aws-cdk-lib/aws-sdb/README.md +27 -0
  263. package/iac/node_modules/aws-cdk-lib/aws-secretsmanager/README.md +285 -0
  264. package/iac/node_modules/aws-cdk-lib/aws-securityhub/README.md +27 -0
  265. package/iac/node_modules/aws-cdk-lib/aws-servicecatalog/README.md +491 -0
  266. package/iac/node_modules/aws-cdk-lib/aws-servicecatalogappregistry/README.md +32 -0
  267. package/iac/node_modules/aws-cdk-lib/aws-servicediscovery/README.md +45 -0
  268. package/iac/node_modules/aws-cdk-lib/aws-ses/README.md +194 -0
  269. package/iac/node_modules/aws-cdk-lib/aws-ses-actions/README.md +16 -0
  270. package/iac/node_modules/aws-cdk-lib/aws-signer/README.md +41 -0
  271. package/iac/node_modules/aws-cdk-lib/aws-sns/README.md +184 -0
  272. package/iac/node_modules/aws-cdk-lib/aws-sns-subscriptions/README.md +120 -0
  273. package/iac/node_modules/aws-cdk-lib/aws-sqs/README.md +57 -0
  274. package/iac/node_modules/aws-cdk-lib/aws-ssm/README.md +99 -0
  275. package/iac/node_modules/aws-cdk-lib/aws-ssmcontacts/README.md +27 -0
  276. package/iac/node_modules/aws-cdk-lib/aws-ssmincidents/README.md +27 -0
  277. package/iac/node_modules/aws-cdk-lib/aws-sso/README.md +27 -0
  278. package/iac/node_modules/aws-cdk-lib/aws-stepfunctions/README.md +884 -0
  279. package/iac/node_modules/aws-cdk-lib/aws-stepfunctions-tasks/README.md +1288 -0
  280. package/iac/node_modules/aws-cdk-lib/aws-supportapp/README.md +27 -0
  281. package/iac/node_modules/aws-cdk-lib/aws-synthetics/README.md +32 -0
  282. package/iac/node_modules/aws-cdk-lib/aws-timestream/README.md +27 -0
  283. package/iac/node_modules/aws-cdk-lib/aws-transfer/README.md +27 -0
  284. package/iac/node_modules/aws-cdk-lib/aws-voiceid/README.md +27 -0
  285. package/iac/node_modules/aws-cdk-lib/aws-waf/README.md +27 -0
  286. package/iac/node_modules/aws-cdk-lib/aws-wafregional/README.md +27 -0
  287. package/iac/node_modules/aws-cdk-lib/aws-wafv2/README.md +27 -0
  288. package/iac/node_modules/aws-cdk-lib/aws-wisdom/README.md +27 -0
  289. package/iac/node_modules/aws-cdk-lib/aws-workspaces/README.md +27 -0
  290. package/iac/node_modules/aws-cdk-lib/aws-xray/README.md +27 -0
  291. package/iac/node_modules/aws-cdk-lib/cloud-assembly-schema/README.md +55 -0
  292. package/iac/node_modules/aws-cdk-lib/cloud-assembly-schema/schema/README.md +5 -0
  293. package/iac/node_modules/aws-cdk-lib/cloudformation-include/README.md +466 -0
  294. package/iac/node_modules/aws-cdk-lib/core/README.md +1078 -0
  295. package/iac/node_modules/aws-cdk-lib/custom-resources/README.md +624 -0
  296. package/iac/node_modules/aws-cdk-lib/cx-api/README.md +98 -0
  297. package/iac/node_modules/aws-cdk-lib/lambda-layer-awscli/README.md +19 -0
  298. package/iac/node_modules/aws-cdk-lib/lambda-layer-kubectl/README.md +20 -0
  299. package/iac/node_modules/aws-cdk-lib/lambda-layer-node-proxy-agent/README.md +18 -0
  300. package/iac/node_modules/aws-cdk-lib/node_modules/@balena/dockerignore/LICENSE.md +206 -0
  301. package/iac/node_modules/aws-cdk-lib/node_modules/@balena/dockerignore/README.md +261 -0
  302. package/iac/node_modules/aws-cdk-lib/node_modules/at-least-node/LICENSE +6 -0
  303. package/iac/node_modules/aws-cdk-lib/node_modules/at-least-node/README.md +25 -0
  304. package/iac/node_modules/aws-cdk-lib/node_modules/balanced-match/LICENSE.md +21 -0
  305. package/iac/node_modules/aws-cdk-lib/node_modules/balanced-match/README.md +97 -0
  306. package/iac/node_modules/aws-cdk-lib/node_modules/brace-expansion/LICENSE +21 -0
  307. package/iac/node_modules/aws-cdk-lib/node_modules/brace-expansion/README.md +129 -0
  308. package/iac/node_modules/aws-cdk-lib/node_modules/case/LICENSE +22 -0
  309. package/iac/node_modules/aws-cdk-lib/node_modules/case/README.md +139 -0
  310. package/iac/node_modules/aws-cdk-lib/node_modules/case/dist/Case.min.js.map +1 -0
  311. package/iac/node_modules/aws-cdk-lib/node_modules/case/dist/Case.plus.min.js.map +1 -0
  312. package/iac/node_modules/aws-cdk-lib/node_modules/concat-map/LICENSE +18 -0
  313. package/iac/node_modules/aws-cdk-lib/node_modules/concat-map/README.markdown +62 -0
  314. package/iac/node_modules/aws-cdk-lib/node_modules/fs-extra/LICENSE +15 -0
  315. package/iac/node_modules/aws-cdk-lib/node_modules/fs-extra/README.md +264 -0
  316. package/iac/node_modules/aws-cdk-lib/node_modules/graceful-fs/LICENSE +15 -0
  317. package/iac/node_modules/aws-cdk-lib/node_modules/graceful-fs/README.md +143 -0
  318. package/iac/node_modules/aws-cdk-lib/node_modules/ignore/README.md +412 -0
  319. package/iac/node_modules/aws-cdk-lib/node_modules/jsonfile/LICENSE +15 -0
  320. package/iac/node_modules/aws-cdk-lib/node_modules/jsonfile/README.md +230 -0
  321. package/iac/node_modules/aws-cdk-lib/node_modules/jsonschema/LICENSE +21 -0
  322. package/iac/node_modules/aws-cdk-lib/node_modules/jsonschema/README.md +421 -0
  323. package/iac/node_modules/aws-cdk-lib/node_modules/lru-cache/LICENSE +15 -0
  324. package/iac/node_modules/aws-cdk-lib/node_modules/lru-cache/README.md +166 -0
  325. package/iac/node_modules/aws-cdk-lib/node_modules/minimatch/LICENSE +15 -0
  326. package/iac/node_modules/aws-cdk-lib/node_modules/minimatch/README.md +230 -0
  327. package/iac/node_modules/aws-cdk-lib/node_modules/punycode/README.md +122 -0
  328. package/iac/node_modules/aws-cdk-lib/node_modules/semver/LICENSE +15 -0
  329. package/iac/node_modules/aws-cdk-lib/node_modules/semver/README.md +568 -0
  330. package/iac/node_modules/aws-cdk-lib/node_modules/universalify/LICENSE +20 -0
  331. package/iac/node_modules/aws-cdk-lib/node_modules/universalify/README.md +76 -0
  332. package/iac/node_modules/aws-cdk-lib/node_modules/yallist/LICENSE +15 -0
  333. package/iac/node_modules/aws-cdk-lib/node_modules/yallist/README.md +204 -0
  334. package/iac/node_modules/aws-cdk-lib/node_modules/yaml/LICENSE +13 -0
  335. package/iac/node_modules/aws-cdk-lib/node_modules/yaml/README.md +127 -0
  336. package/iac/node_modules/aws-cdk-lib/pipelines/README.md +1573 -0
  337. package/iac/node_modules/aws-cdk-lib/region-info/README.md +84 -0
  338. package/iac/node_modules/aws-cdk-lib/triggers/README.md +86 -0
  339. package/iac/node_modules/balanced-match/LICENSE.md +21 -0
  340. package/iac/node_modules/balanced-match/README.md +97 -0
  341. package/iac/node_modules/brace-expansion/LICENSE +21 -0
  342. package/iac/node_modules/brace-expansion/README.md +129 -0
  343. package/iac/node_modules/buffer-from/LICENSE +21 -0
  344. package/iac/node_modules/buffer-from/readme.md +69 -0
  345. package/iac/node_modules/case/LICENSE +22 -0
  346. package/iac/node_modules/case/README.md +139 -0
  347. package/iac/node_modules/case/dist/Case.min.js.map +1 -0
  348. package/iac/node_modules/case/dist/Case.plus.min.js.map +1 -0
  349. package/iac/node_modules/chalk/license +9 -0
  350. package/iac/node_modules/chalk/node_modules/ansi-styles/license +9 -0
  351. package/iac/node_modules/chalk/node_modules/ansi-styles/readme.md +152 -0
  352. package/iac/node_modules/chalk/readme.md +341 -0
  353. package/iac/node_modules/color-convert/LICENSE +21 -0
  354. package/iac/node_modules/color-convert/README.md +68 -0
  355. package/iac/node_modules/color-name/LICENSE +8 -0
  356. package/iac/node_modules/color-name/README.md +11 -0
  357. package/iac/node_modules/concat-map/LICENSE +18 -0
  358. package/iac/node_modules/concat-map/README.markdown +62 -0
  359. package/iac/node_modules/constructs/LICENSE +202 -0
  360. package/iac/node_modules/constructs/README.md +28 -0
  361. package/iac/node_modules/create-require/LICENSE +25 -0
  362. package/iac/node_modules/create-require/README.md +46 -0
  363. package/iac/node_modules/diff/LICENSE +31 -0
  364. package/iac/node_modules/diff/README.md +207 -0
  365. package/iac/node_modules/diff-sequences/LICENSE +21 -0
  366. package/iac/node_modules/diff-sequences/README.md +404 -0
  367. package/iac/node_modules/fs-extra/LICENSE +15 -0
  368. package/iac/node_modules/fs-extra/README.md +264 -0
  369. package/iac/node_modules/fsevents/LICENSE +22 -0
  370. package/iac/node_modules/fsevents/README.md +83 -0
  371. package/iac/node_modules/graceful-fs/LICENSE +15 -0
  372. package/iac/node_modules/graceful-fs/README.md +143 -0
  373. package/iac/node_modules/has-flag/license +9 -0
  374. package/iac/node_modules/has-flag/readme.md +89 -0
  375. package/iac/node_modules/ignore/README.md +412 -0
  376. package/iac/node_modules/jest-diff/LICENSE +21 -0
  377. package/iac/node_modules/jest-diff/README.md +671 -0
  378. package/iac/node_modules/jest-get-type/LICENSE +21 -0
  379. package/iac/node_modules/jest-matcher-utils/LICENSE +21 -0
  380. package/iac/node_modules/jest-matcher-utils/README.md +24 -0
  381. package/iac/node_modules/jsonfile/LICENSE +15 -0
  382. package/iac/node_modules/jsonfile/README.md +230 -0
  383. package/iac/node_modules/jsonschema/LICENSE +21 -0
  384. package/iac/node_modules/jsonschema/README.md +421 -0
  385. package/iac/node_modules/lru-cache/LICENSE +15 -0
  386. package/iac/node_modules/lru-cache/README.md +166 -0
  387. package/iac/node_modules/make-error/LICENSE +5 -0
  388. package/iac/node_modules/make-error/README.md +112 -0
  389. package/iac/node_modules/minimatch/LICENSE +15 -0
  390. package/iac/node_modules/minimatch/README.md +230 -0
  391. package/iac/node_modules/pretty-format/LICENSE +21 -0
  392. package/iac/node_modules/pretty-format/README.md +458 -0
  393. package/iac/node_modules/punycode/README.md +122 -0
  394. package/iac/node_modules/react-is/LICENSE +21 -0
  395. package/iac/node_modules/react-is/README.md +104 -0
  396. package/iac/node_modules/semver/LICENSE +15 -0
  397. package/iac/node_modules/semver/README.md +568 -0
  398. package/iac/node_modules/source-map/LICENSE +28 -0
  399. package/iac/node_modules/source-map/README.md +742 -0
  400. package/iac/node_modules/source-map/dist/source-map.min.js.map +1 -0
  401. package/iac/node_modules/source-map-support/LICENSE.md +21 -0
  402. package/iac/node_modules/source-map-support/README.md +284 -0
  403. package/iac/node_modules/supports-color/license +9 -0
  404. package/iac/node_modules/supports-color/readme.md +76 -0
  405. package/iac/node_modules/ts-node/LICENSE +21 -0
  406. package/iac/node_modules/ts-node/README.md +1442 -0
  407. package/iac/node_modules/ts-node/dist/bin-cwd.js.map +1 -0
  408. package/iac/node_modules/ts-node/dist/bin-esm.js.map +1 -0
  409. package/iac/node_modules/ts-node/dist/bin-script-deprecated.js.map +1 -0
  410. package/iac/node_modules/ts-node/dist/bin-script.js.map +1 -0
  411. package/iac/node_modules/ts-node/dist/bin-transpile.js.map +1 -0
  412. package/iac/node_modules/ts-node/dist/bin.js.map +1 -0
  413. package/iac/node_modules/ts-node/dist/child/argv-payload.js.map +1 -0
  414. package/iac/node_modules/ts-node/dist/child/child-entrypoint.js.map +1 -0
  415. package/iac/node_modules/ts-node/dist/child/child-loader.js.map +1 -0
  416. package/iac/node_modules/ts-node/dist/child/child-require.js.map +1 -0
  417. package/iac/node_modules/ts-node/dist/child/spawn-child.js.map +1 -0
  418. package/iac/node_modules/ts-node/dist/cjs-resolve-hooks.js.map +1 -0
  419. package/iac/node_modules/ts-node/dist/configuration.js.map +1 -0
  420. package/iac/node_modules/ts-node/dist/esm.js.map +1 -0
  421. package/iac/node_modules/ts-node/dist/file-extensions.js.map +1 -0
  422. package/iac/node_modules/ts-node/dist/index.js.map +1 -0
  423. package/iac/node_modules/ts-node/dist/module-type-classifier.js.map +1 -0
  424. package/iac/node_modules/ts-node/dist/node-module-type-classifier.js.map +1 -0
  425. package/iac/node_modules/ts-node/dist/repl.js.map +1 -0
  426. package/iac/node_modules/ts-node/dist/resolver-functions.js.map +1 -0
  427. package/iac/node_modules/ts-node/dist/transpilers/swc.js.map +1 -0
  428. package/iac/node_modules/ts-node/dist/transpilers/types.js.map +1 -0
  429. package/iac/node_modules/ts-node/dist/ts-compiler-types.js.map +1 -0
  430. package/iac/node_modules/ts-node/dist/ts-internals.js.map +1 -0
  431. package/iac/node_modules/ts-node/dist/ts-transpile-module.js.map +1 -0
  432. package/iac/node_modules/ts-node/dist/tsconfig-schema.js.map +1 -0
  433. package/iac/node_modules/ts-node/dist/tsconfigs.js.map +1 -0
  434. package/iac/node_modules/ts-node/dist/util.js.map +1 -0
  435. package/iac/node_modules/ts-node/dist-raw/README.md +36 -0
  436. package/iac/node_modules/typescript/LICENSE.txt +55 -0
  437. package/iac/node_modules/typescript/README.md +104 -0
  438. package/iac/node_modules/typescript/lib/README.md +5 -0
  439. package/iac/node_modules/universalify/LICENSE +20 -0
  440. package/iac/node_modules/universalify/README.md +76 -0
  441. package/iac/node_modules/v8-compile-cache-lib/LICENSE +21 -0
  442. package/iac/node_modules/v8-compile-cache-lib/README.md +60 -0
  443. package/iac/node_modules/yallist/LICENSE +15 -0
  444. package/iac/node_modules/yallist/README.md +204 -0
  445. package/iac/node_modules/yaml/LICENSE +13 -0
  446. package/iac/node_modules/yaml/README.md +127 -0
  447. package/iac/node_modules/yn/license +9 -0
  448. package/iac/node_modules/yn/readme.md +83 -0
  449. package/index.d.ts +1 -0
  450. package/index.js +18 -0
  451. package/index.js.map +1 -0
  452. package/package.json +26 -5
  453. package/react/Edit.d.ts +3 -0
  454. package/react/Edit.js +10 -0
  455. package/react/Edit.js.map +1 -0
  456. package/react/index.d.ts +1 -0
  457. package/react/index.js +18 -0
  458. package/react/index.js.map +1 -0
  459. package/src/material-symbols.d.ts +4 -0
@@ -0,0 +1,1514 @@
1
+ # Amazon EC2 Construct Library
2
+
3
+
4
+
5
+ The `@aws-cdk/aws-ec2` package contains primitives for setting up networking and
6
+ instances.
7
+
8
+ ```ts nofixture
9
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
10
+ ```
11
+
12
+ ## VPC
13
+
14
+ Most projects need a Virtual Private Cloud to provide security by means of
15
+ network partitioning. This is achieved by creating an instance of
16
+ `Vpc`:
17
+
18
+ ```ts
19
+ const vpc = new ec2.Vpc(this, 'VPC');
20
+ ```
21
+
22
+ All default constructs require EC2 instances to be launched inside a VPC, so
23
+ you should generally start by defining a VPC whenever you need to launch
24
+ instances for your project.
25
+
26
+ ### Subnet Types
27
+
28
+ A VPC consists of one or more subnets that instances can be placed into. CDK
29
+ distinguishes three different subnet types:
30
+
31
+ * **Public (`SubnetType.PUBLIC`)** - public subnets connect directly to the Internet using an
32
+ Internet Gateway. If you want your instances to have a public IP address
33
+ and be directly reachable from the Internet, you must place them in a
34
+ public subnet.
35
+ * **Private with Internet Access (`SubnetType.PRIVATE_WITH_EGRESS`)** - instances in private subnets are not directly routable from the
36
+ Internet, and you must provide a way to connect out to the Internet.
37
+ By default, a NAT gateway is created in every public subnet for maximum availability. Be
38
+ aware that you will be charged for NAT gateways.
39
+ Alternatively you can set `natGateways:0` and provide your own egress configuration (i.e through Transit Gateway)
40
+ * **Isolated (`SubnetType.PRIVATE_ISOLATED`)** - isolated subnets do not route from or to the Internet, and
41
+ as such do not require NAT gateways. They can only connect to or be
42
+ connected to from other instances in the same VPC. A default VPC configuration
43
+ will not include isolated subnets,
44
+
45
+ A default VPC configuration will create public and **private** subnets. However, if
46
+ `natGateways:0` **and** `subnetConfiguration` is undefined, default VPC configuration
47
+ will create public and **isolated** subnets. See [*Advanced Subnet Configuration*](#advanced-subnet-configuration)
48
+ below for information on how to change the default subnet configuration.
49
+
50
+ Constructs using the VPC will "launch instances" (or more accurately, create
51
+ Elastic Network Interfaces) into one or more of the subnets. They all accept
52
+ a property called `subnetSelection` (sometimes called `vpcSubnets`) to allow
53
+ you to select in what subnet to place the ENIs, usually defaulting to
54
+ *private* subnets if the property is omitted.
55
+
56
+ If you would like to save on the cost of NAT gateways, you can use
57
+ *isolated* subnets instead of *private* subnets (as described in Advanced
58
+ *Subnet Configuration*). If you need private instances to have
59
+ internet connectivity, another option is to reduce the number of NAT gateways
60
+ created by setting the `natGateways` property to a lower value (the default
61
+ is one NAT gateway per availability zone). Be aware that this may have
62
+ availability implications for your application.
63
+
64
+ [Read more about
65
+ subnets](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html).
66
+
67
+ ### Control over availability zones
68
+
69
+ By default, a VPC will spread over at most 3 Availability Zones available to
70
+ it. To change the number of Availability Zones that the VPC will spread over,
71
+ specify the `maxAzs` property when defining it.
72
+
73
+ The number of Availability Zones that are available depends on the *region*
74
+ and *account* of the Stack containing the VPC. If the [region and account are
75
+ specified](https://docs.aws.amazon.com/cdk/latest/guide/environments.html) on
76
+ the Stack, the CLI will [look up the existing Availability
77
+ Zones](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#using-regions-availability-zones-describe)
78
+ and get an accurate count. If region and account are not specified, the stack
79
+ could be deployed anywhere and it will have to make a safe choice, limiting
80
+ itself to 2 Availability Zones.
81
+
82
+ Therefore, to get the VPC to spread over 3 or more availability zones, you
83
+ must specify the environment where the stack will be deployed.
84
+
85
+ You can gain full control over the availability zones selection strategy by overriding the Stack's [`get availabilityZones()`](https://github.com/aws/aws-cdk/blob/main/packages/@aws-cdk/core/lib/stack.ts) method:
86
+
87
+ ```text
88
+ // This example is only available in TypeScript
89
+
90
+ class MyStack extends Stack {
91
+
92
+ constructor(scope: Construct, id: string, props?: StackProps) {
93
+ super(scope, id, props);
94
+
95
+ // ...
96
+ }
97
+
98
+ get availabilityZones(): string[] {
99
+ return ['us-west-2a', 'us-west-2b'];
100
+ }
101
+
102
+ }
103
+ ```
104
+
105
+ Note that overriding the `get availabilityZones()` method will override the default behavior for all constructs defined within the Stack.
106
+
107
+ ### Choosing subnets for resources
108
+
109
+ When creating resources that create Elastic Network Interfaces (such as
110
+ databases or instances), there is an option to choose which subnets to place
111
+ them in. For example, a VPC endpoint by default is placed into a subnet in
112
+ every availability zone, but you can override which subnets to use. The property
113
+ is typically called one of `subnets`, `vpcSubnets` or `subnetSelection`.
114
+
115
+ The example below will place the endpoint into two AZs (`us-east-1a` and `us-east-1c`),
116
+ in Isolated subnets:
117
+
118
+ ```ts
119
+ declare const vpc: ec2.Vpc;
120
+
121
+ new ec2.InterfaceVpcEndpoint(this, 'VPC Endpoint', {
122
+ vpc,
123
+ service: new ec2.InterfaceVpcEndpointService('com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc', 443),
124
+ subnets: {
125
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
126
+ availabilityZones: ['us-east-1a', 'us-east-1c']
127
+ }
128
+ });
129
+ ```
130
+
131
+ You can also specify specific subnet objects for granular control:
132
+
133
+ ```ts
134
+ declare const vpc: ec2.Vpc;
135
+ declare const subnet1: ec2.Subnet;
136
+ declare const subnet2: ec2.Subnet;
137
+
138
+ new ec2.InterfaceVpcEndpoint(this, 'VPC Endpoint', {
139
+ vpc,
140
+ service: new ec2.InterfaceVpcEndpointService('com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc', 443),
141
+ subnets: {
142
+ subnets: [subnet1, subnet2]
143
+ }
144
+ });
145
+ ```
146
+
147
+ Which subnets are selected is evaluated as follows:
148
+
149
+ * `subnets`: if specific subnet objects are supplied, these are selected, and no other
150
+ logic is used.
151
+ * `subnetType`/`subnetGroupName`: otherwise, a set of subnets is selected by
152
+ supplying either type or name:
153
+ * `subnetType` will select all subnets of the given type.
154
+ * `subnetGroupName` should be used to distinguish between multiple groups of subnets of
155
+ the same type (for example, you may want to separate your application instances and your
156
+ RDS instances into two distinct groups of Isolated subnets).
157
+ * If neither are given, the first available subnet group of a given type that
158
+ exists in the VPC will be used, in this order: Private, then Isolated, then Public.
159
+ In short: by default ENIs will preferentially be placed in subnets not connected to
160
+ the Internet.
161
+ * `availabilityZones`/`onePerAz`: finally, some availability-zone based filtering may be done.
162
+ This filtering by availability zones will only be possible if the VPC has been created or
163
+ looked up in a non-environment agnostic stack (so account and region have been set and
164
+ availability zones have been looked up).
165
+ * `availabilityZones`: only the specific subnets from the selected subnet groups that are
166
+ in the given availability zones will be returned.
167
+ * `onePerAz`: per availability zone, a maximum of one subnet will be returned (Useful for resource
168
+ types that do not allow creating two ENIs in the same availability zone).
169
+ * `subnetFilters`: additional filtering on subnets using any number of user-provided filters which
170
+ extend `SubnetFilter`. The following methods on the `SubnetFilter` class can be used to create
171
+ a filter:
172
+ * `byIds`: chooses subnets from a list of ids
173
+ * `availabilityZones`: chooses subnets in the provided list of availability zones
174
+ * `onePerAz`: chooses at most one subnet per availability zone
175
+ * `containsIpAddresses`: chooses a subnet which contains *any* of the listed ip addresses
176
+ * `byCidrMask`: chooses subnets that have the provided CIDR netmask
177
+
178
+ ### Using NAT instances
179
+
180
+ By default, the `Vpc` construct will create NAT *gateways* for you, which
181
+ are managed by AWS. If you would prefer to use your own managed NAT
182
+ *instances* instead, specify a different value for the `natGatewayProvider`
183
+ property, as follows:
184
+
185
+ [using NAT instances](test/integ.nat-instances.lit.ts)
186
+
187
+ The construct will automatically search for the most recent NAT gateway AMI.
188
+ If you prefer to use a custom AMI, use `machineImage:
189
+ MachineImage.genericLinux({ ... })` and configure the right AMI ID for the
190
+ regions you want to deploy to.
191
+
192
+ By default, the NAT instances will route all traffic. To control what traffic
193
+ gets routed, pass a custom value for `defaultAllowedTraffic` and access the
194
+ `NatInstanceProvider.connections` member after having passed the NAT provider to
195
+ the VPC:
196
+
197
+ ```ts
198
+ declare const instanceType: ec2.InstanceType;
199
+
200
+ const provider = ec2.NatProvider.instance({
201
+ instanceType,
202
+ defaultAllowedTraffic: ec2.NatTrafficDirection.OUTBOUND_ONLY,
203
+ });
204
+ new ec2.Vpc(this, 'TheVPC', {
205
+ natGatewayProvider: provider,
206
+ });
207
+ provider.connections.allowFrom(ec2.Peer.ipv4('1.2.3.4/8'), ec2.Port.tcp(80));
208
+ ```
209
+
210
+ ### Advanced Subnet Configuration
211
+
212
+ If the default VPC configuration (public and private subnets spanning the
213
+ size of the VPC) don't suffice for you, you can configure what subnets to
214
+ create by specifying the `subnetConfiguration` property. It allows you
215
+ to configure the number and size of all subnets. Specifying an advanced
216
+ subnet configuration could look like this:
217
+
218
+ ```ts
219
+ const vpc = new ec2.Vpc(this, 'TheVPC', {
220
+ // 'cidr' configures the IP range and size of the entire VPC.
221
+ // The IP space will be divided over the configured subnets.
222
+ cidr: '10.0.0.0/21',
223
+
224
+ // 'maxAzs' configures the maximum number of availability zones to use.
225
+ // If you want to specify the exact availability zones you want the VPC
226
+ // to use, use `availabilityZones` instead.
227
+ maxAzs: 3,
228
+
229
+ // 'subnetConfiguration' specifies the "subnet groups" to create.
230
+ // Every subnet group will have a subnet for each AZ, so this
231
+ // configuration will create `3 groups × 3 AZs = 9` subnets.
232
+ subnetConfiguration: [
233
+ {
234
+ // 'subnetType' controls Internet access, as described above.
235
+ subnetType: ec2.SubnetType.PUBLIC,
236
+
237
+ // 'name' is used to name this particular subnet group. You will have to
238
+ // use the name for subnet selection if you have more than one subnet
239
+ // group of the same type.
240
+ name: 'Ingress',
241
+
242
+ // 'cidrMask' specifies the IP addresses in the range of of individual
243
+ // subnets in the group. Each of the subnets in this group will contain
244
+ // `2^(32 address bits - 24 subnet bits) - 2 reserved addresses = 254`
245
+ // usable IP addresses.
246
+ //
247
+ // If 'cidrMask' is left out the available address space is evenly
248
+ // divided across the remaining subnet groups.
249
+ cidrMask: 24,
250
+ },
251
+ {
252
+ cidrMask: 24,
253
+ name: 'Application',
254
+ subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
255
+ },
256
+ {
257
+ cidrMask: 28,
258
+ name: 'Database',
259
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
260
+
261
+ // 'reserved' can be used to reserve IP address space. No resources will
262
+ // be created for this subnet, but the IP range will be kept available for
263
+ // future creation of this subnet, or even for future subdivision.
264
+ reserved: true
265
+ }
266
+ ],
267
+ });
268
+ ```
269
+
270
+ The example above is one possible configuration, but the user can use the
271
+ constructs above to implement many other network configurations.
272
+
273
+ The `Vpc` from the above configuration in a Region with three
274
+ availability zones will be the following:
275
+
276
+ Subnet Name |Type |IP Block |AZ|Features
277
+ ------------------|----------|--------------|--|--------
278
+ IngressSubnet1 |`PUBLIC` |`10.0.0.0/24` |#1|NAT Gateway
279
+ IngressSubnet2 |`PUBLIC` |`10.0.1.0/24` |#2|NAT Gateway
280
+ IngressSubnet3 |`PUBLIC` |`10.0.2.0/24` |#3|NAT Gateway
281
+ ApplicationSubnet1|`PRIVATE` |`10.0.3.0/24` |#1|Route to NAT in IngressSubnet1
282
+ ApplicationSubnet2|`PRIVATE` |`10.0.4.0/24` |#2|Route to NAT in IngressSubnet2
283
+ ApplicationSubnet3|`PRIVATE` |`10.0.5.0/24` |#3|Route to NAT in IngressSubnet3
284
+ DatabaseSubnet1 |`ISOLATED`|`10.0.6.0/28` |#1|Only routes within the VPC
285
+ DatabaseSubnet2 |`ISOLATED`|`10.0.6.16/28`|#2|Only routes within the VPC
286
+ DatabaseSubnet3 |`ISOLATED`|`10.0.6.32/28`|#3|Only routes within the VPC
287
+
288
+ ### Accessing the Internet Gateway
289
+
290
+ If you need access to the internet gateway, you can get its ID like so:
291
+
292
+ ```ts
293
+ declare const vpc: ec2.Vpc;
294
+
295
+ const igwId = vpc.internetGatewayId;
296
+ ```
297
+
298
+ For a VPC with only `ISOLATED` subnets, this value will be undefined.
299
+
300
+ This is only supported for VPCs created in the stack - currently you're
301
+ unable to get the ID for imported VPCs. To do that you'd have to specifically
302
+ look up the Internet Gateway by name, which would require knowing the name
303
+ beforehand.
304
+
305
+ This can be useful for configuring routing using a combination of gateways:
306
+ for more information see [Routing](#routing) below.
307
+
308
+ #### Routing
309
+
310
+ It's possible to add routes to any subnets using the `addRoute()` method. If for
311
+ example you want an isolated subnet to have a static route via the default
312
+ Internet Gateway created for the public subnet - perhaps for routing a VPN
313
+ connection - you can do so like this:
314
+
315
+ ```ts
316
+ const vpc = new ec2.Vpc(this, "VPC", {
317
+ subnetConfiguration: [{
318
+ subnetType: ec2.SubnetType.PUBLIC,
319
+ name: 'Public',
320
+ },{
321
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
322
+ name: 'Isolated',
323
+ }]
324
+ });
325
+
326
+ (vpc.isolatedSubnets[0] as ec2.Subnet).addRoute("StaticRoute", {
327
+ routerId: vpc.internetGatewayId!,
328
+ routerType: ec2.RouterType.GATEWAY,
329
+ destinationCidrBlock: "8.8.8.8/32",
330
+ })
331
+ ```
332
+
333
+ *Note that we cast to `Subnet` here because the list of subnets only returns an
334
+ `ISubnet`.*
335
+
336
+ ### Reserving subnet IP space
337
+
338
+ There are situations where the IP space for a subnet or number of subnets
339
+ will need to be reserved. This is useful in situations where subnets would
340
+ need to be added after the vpc is originally deployed, without causing IP
341
+ renumbering for existing subnets. The IP space for a subnet may be reserved
342
+ by setting the `reserved` subnetConfiguration property to true, as shown
343
+ below:
344
+
345
+ ```ts
346
+ const vpc = new ec2.Vpc(this, 'TheVPC', {
347
+ natGateways: 1,
348
+ subnetConfiguration: [
349
+ {
350
+ cidrMask: 26,
351
+ name: 'Public',
352
+ subnetType: ec2.SubnetType.PUBLIC,
353
+ },
354
+ {
355
+ cidrMask: 26,
356
+ name: 'Application1',
357
+ subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
358
+ },
359
+ {
360
+ cidrMask: 26,
361
+ name: 'Application2',
362
+ subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
363
+ reserved: true, // <---- This subnet group is reserved
364
+ },
365
+ {
366
+ cidrMask: 27,
367
+ name: 'Database',
368
+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
369
+ }
370
+ ],
371
+ });
372
+ ```
373
+
374
+ In the example above, the subnet for Application2 is not actually provisioned
375
+ but its IP space is still reserved. If in the future this subnet needs to be
376
+ provisioned, then the `reserved: true` property should be removed. Reserving
377
+ parts of the IP space prevents the other subnets from getting renumbered.
378
+
379
+ ### Sharing VPCs between stacks
380
+
381
+ If you are creating multiple `Stack`s inside the same CDK application, you
382
+ can reuse a VPC defined in one Stack in another by simply passing the VPC
383
+ instance around:
384
+
385
+ [sharing VPCs between stacks](test/integ.share-vpcs.lit.ts)
386
+
387
+ ### Importing an existing VPC
388
+
389
+ If your VPC is created outside your CDK app, you can use `Vpc.fromLookup()`.
390
+ The CDK CLI will search for the specified VPC in the the stack's region and
391
+ account, and import the subnet configuration. Looking up can be done by VPC
392
+ ID, but more flexibly by searching for a specific tag on the VPC.
393
+
394
+ Subnet types will be determined from the `aws-cdk:subnet-type` tag on the
395
+ subnet if it exists, or the presence of a route to an Internet Gateway
396
+ otherwise. Subnet names will be determined from the `aws-cdk:subnet-name` tag
397
+ on the subnet if it exists, or will mirror the subnet type otherwise (i.e.
398
+ a public subnet will have the name `"Public"`).
399
+
400
+ The result of the `Vpc.fromLookup()` operation will be written to a file
401
+ called `cdk.context.json`. You must commit this file to source control so
402
+ that the lookup values are available in non-privileged environments such
403
+ as CI build steps, and to ensure your template builds are repeatable.
404
+
405
+ Here's how `Vpc.fromLookup()` can be used:
406
+
407
+ [importing existing VPCs](test/integ.import-default-vpc.lit.ts)
408
+
409
+ `Vpc.fromLookup` is the recommended way to import VPCs. If for whatever
410
+ reason you do not want to use the context mechanism to look up a VPC at
411
+ synthesis time, you can also use `Vpc.fromVpcAttributes`. This has the
412
+ following limitations:
413
+
414
+ * Every subnet group in the VPC must have a subnet in each availability zone
415
+ (for example, each AZ must have both a public and private subnet). Asymmetric
416
+ VPCs are not supported.
417
+ * All VpcId, SubnetId, RouteTableId, ... parameters must either be known at
418
+ synthesis time, or they must come from deploy-time list parameters whose
419
+ deploy-time lengths are known at synthesis time.
420
+
421
+ Using `Vpc.fromVpcAttributes()` looks like this:
422
+
423
+ ```ts
424
+ const vpc = ec2.Vpc.fromVpcAttributes(this, 'VPC', {
425
+ vpcId: 'vpc-1234',
426
+ availabilityZones: ['us-east-1a', 'us-east-1b'],
427
+
428
+ // Either pass literals for all IDs
429
+ publicSubnetIds: ['s-12345', 's-67890'],
430
+
431
+ // OR: import a list of known length
432
+ privateSubnetIds: Fn.importListValue('PrivateSubnetIds', 2),
433
+
434
+ // OR: split an imported string to a list of known length
435
+ isolatedSubnetIds: Fn.split(',', ssm.StringParameter.valueForStringParameter(this, `MyParameter`), 2),
436
+ });
437
+ ```
438
+
439
+ ## Allowing Connections
440
+
441
+ In AWS, all network traffic in and out of **Elastic Network Interfaces** (ENIs)
442
+ is controlled by **Security Groups**. You can think of Security Groups as a
443
+ firewall with a set of rules. By default, Security Groups allow no incoming
444
+ (ingress) traffic and all outgoing (egress) traffic. You can add ingress rules
445
+ to them to allow incoming traffic streams. To exert fine-grained control over
446
+ egress traffic, set `allowAllOutbound: false` on the `SecurityGroup`, after
447
+ which you can add egress traffic rules.
448
+
449
+ You can manipulate Security Groups directly:
450
+
451
+ ```ts fixture=with-vpc
452
+ const mySecurityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', {
453
+ vpc,
454
+ description: 'Allow ssh access to ec2 instances',
455
+ allowAllOutbound: true // Can be set to false
456
+ });
457
+ mySecurityGroup.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(22), 'allow ssh access from the world');
458
+ ```
459
+
460
+ All constructs that create ENIs on your behalf (typically constructs that create
461
+ EC2 instances or other VPC-connected resources) will all have security groups
462
+ automatically assigned. Those constructs have an attribute called
463
+ **connections**, which is an object that makes it convenient to update the
464
+ security groups. If you want to allow connections between two constructs that
465
+ have security groups, you have to add an **Egress** rule to one Security Group,
466
+ and an **Ingress** rule to the other. The connections object will automatically
467
+ take care of this for you:
468
+
469
+ ```ts
470
+ declare const loadBalancer: elbv2.ApplicationLoadBalancer;
471
+ declare const appFleet: autoscaling.AutoScalingGroup;
472
+ declare const dbFleet: autoscaling.AutoScalingGroup;
473
+
474
+ // Allow connections from anywhere
475
+ loadBalancer.connections.allowFromAnyIpv4(ec2.Port.tcp(443), 'Allow inbound HTTPS');
476
+
477
+ // The same, but an explicit IP address
478
+ loadBalancer.connections.allowFrom(ec2.Peer.ipv4('1.2.3.4/32'), ec2.Port.tcp(443), 'Allow inbound HTTPS');
479
+
480
+ // Allow connection between AutoScalingGroups
481
+ appFleet.connections.allowTo(dbFleet, ec2.Port.tcp(443), 'App can call database');
482
+ ```
483
+
484
+ ### Connection Peers
485
+
486
+ There are various classes that implement the connection peer part:
487
+
488
+ ```ts
489
+ declare const appFleet: autoscaling.AutoScalingGroup;
490
+ declare const dbFleet: autoscaling.AutoScalingGroup;
491
+
492
+ // Simple connection peers
493
+ let peer = ec2.Peer.ipv4('10.0.0.0/16');
494
+ peer = ec2.Peer.anyIpv4();
495
+ peer = ec2.Peer.ipv6('::0/0');
496
+ peer = ec2.Peer.anyIpv6();
497
+ peer = ec2.Peer.prefixList('pl-12345');
498
+ appFleet.connections.allowTo(peer, ec2.Port.tcp(443), 'Allow outbound HTTPS');
499
+ ```
500
+
501
+ Any object that has a security group can itself be used as a connection peer:
502
+
503
+ ```ts
504
+ declare const fleet1: autoscaling.AutoScalingGroup;
505
+ declare const fleet2: autoscaling.AutoScalingGroup;
506
+ declare const appFleet: autoscaling.AutoScalingGroup;
507
+
508
+ // These automatically create appropriate ingress and egress rules in both security groups
509
+ fleet1.connections.allowTo(fleet2, ec2.Port.tcp(80), 'Allow between fleets');
510
+
511
+ appFleet.connections.allowFromAnyIpv4(ec2.Port.tcp(80), 'Allow from load balancer');
512
+ ```
513
+
514
+ ### Port Ranges
515
+
516
+ The connections that are allowed are specified by port ranges. A number of classes provide
517
+ the connection specifier:
518
+
519
+ ```ts
520
+ ec2.Port.tcp(80)
521
+ ec2.Port.tcpRange(60000, 65535)
522
+ ec2.Port.allTcp()
523
+ ec2.Port.allIcmp()
524
+ ec2.Port.allIcmpV6()
525
+ ec2.Port.allTraffic()
526
+ ```
527
+
528
+ > NOTE: Not all protocols have corresponding helper methods. In the absence of a helper method,
529
+ > you can instantiate `Port` yourself with your own settings. You are also welcome to contribute
530
+ > new helper methods.
531
+
532
+ ### Default Ports
533
+
534
+ Some Constructs have default ports associated with them. For example, the
535
+ listener of a load balancer does (it's the public port), or instances of an
536
+ RDS database (it's the port the database is accepting connections on).
537
+
538
+ If the object you're calling the peering method on has a default port associated with it, you can call
539
+ `allowDefaultPortFrom()` and omit the port specifier. If the argument has an associated default port, call
540
+ `allowDefaultPortTo()`.
541
+
542
+ For example:
543
+
544
+ ```ts
545
+ declare const listener: elbv2.ApplicationListener;
546
+ declare const appFleet: autoscaling.AutoScalingGroup;
547
+ declare const rdsDatabase: rds.DatabaseCluster;
548
+
549
+ // Port implicit in listener
550
+ listener.connections.allowDefaultPortFromAnyIpv4('Allow public');
551
+
552
+ // Port implicit in peer
553
+ appFleet.connections.allowDefaultPortTo(rdsDatabase, 'Fleet can access database');
554
+ ```
555
+
556
+ ### Security group rules
557
+
558
+ By default, security group wills be added inline to the security group in the output cloud formation
559
+ template, if applicable. This includes any static rules by ip address and port range. This
560
+ optimization helps to minimize the size of the template.
561
+
562
+ In some environments this is not desirable, for example if your security group access is controlled
563
+ via tags. You can disable inline rules per security group or globally via the context key
564
+ `@aws-cdk/aws-ec2.securityGroupDisableInlineRules`.
565
+
566
+ ```ts fixture=with-vpc
567
+ const mySecurityGroupWithoutInlineRules = new ec2.SecurityGroup(this, 'SecurityGroup', {
568
+ vpc,
569
+ description: 'Allow ssh access to ec2 instances',
570
+ allowAllOutbound: true,
571
+ disableInlineRules: true
572
+ });
573
+ //This will add the rule as an external cloud formation construct
574
+ mySecurityGroupWithoutInlineRules.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(22), 'allow ssh access from the world');
575
+ ```
576
+
577
+ ### Importing an existing security group
578
+
579
+ If you know the ID and the configuration of the security group to import, you can use `SecurityGroup.fromSecurityGroupId`:
580
+
581
+ ```ts
582
+ const sg = ec2.SecurityGroup.fromSecurityGroupId(this, 'SecurityGroupImport', 'sg-1234', {
583
+ allowAllOutbound: true,
584
+ });
585
+ ```
586
+
587
+ Alternatively, use lookup methods to import security groups if you do not know the ID or the configuration details. Method `SecurityGroup.fromLookupByName` looks up a security group if the secruity group ID is unknown.
588
+
589
+ ```ts fixture=with-vpc
590
+ const sg = ec2.SecurityGroup.fromLookupByName(this, 'SecurityGroupLookup', 'security-group-name', vpc);
591
+ ```
592
+
593
+ If the security group ID is known and configuration details are unknown, use method `SecurityGroup.fromLookupById` instead. This method will lookup property `allowAllOutbound` from the current configuration of the security group.
594
+
595
+ ```ts
596
+ const sg = ec2.SecurityGroup.fromLookupById(this, 'SecurityGroupLookup', 'sg-1234');
597
+ ```
598
+
599
+ The result of `SecurityGroup.fromLookupByName` and `SecurityGroup.fromLookupById` operations will be written to a file called `cdk.context.json`. You must commit this file to source control so that the lookup values are available in non-privileged environments such as CI build steps, and to ensure your template builds are repeatable.
600
+
601
+ ### Cross Stack Connections
602
+
603
+ If you are attempting to add a connection from a peer in one stack to a peer in a different stack, sometimes it is necessary to ensure that you are making the connection in
604
+ a specific stack in order to avoid a cyclic reference. If there are no other dependencies between stacks then it will not matter in which stack you make
605
+ the connection, but if there are existing dependencies (i.e. stack1 already depends on stack2), then it is important to make the connection in the dependent stack (i.e. stack1).
606
+
607
+ Whenever you make a `connections` function call, the ingress and egress security group rules will be added to the stack that the calling object exists in.
608
+ So if you are doing something like `peer1.connections.allowFrom(peer2)`, then the security group rules (both ingress and egress) will be created in `peer1`'s Stack.
609
+
610
+ As an example, if we wanted to allow a connection from a security group in one stack (egress) to a security group in a different stack (ingress),
611
+ we would make the connection like:
612
+
613
+ **If Stack1 depends on Stack2**
614
+
615
+ ```ts fixture=with-vpc
616
+ // Stack 1
617
+ declare const stack1: Stack;
618
+ declare const stack2: Stack;
619
+
620
+ const sg1 = new ec2.SecurityGroup(stack1, 'SG1', {
621
+ allowAllOutbound: false, // if this is `true` then no egress rule will be created
622
+ vpc,
623
+ });
624
+
625
+ // Stack 2
626
+ const sg2 = new ec2.SecurityGroup(stack2, 'SG2', {
627
+ allowAllOutbound: false, // if this is `true` then no egress rule will be created
628
+ vpc,
629
+ });
630
+
631
+
632
+ // `connections.allowTo` on `sg1` since we want the
633
+ // rules to be created in Stack1
634
+ sg1.connections.allowTo(sg2, ec2.Port.tcp(3333));
635
+ ```
636
+
637
+ In this case both the Ingress Rule for `sg2` and the Egress Rule for `sg1` will both be created
638
+ in `Stack 1` which avoids the cyclic reference.
639
+
640
+
641
+ **If Stack2 depends on Stack1**
642
+
643
+ ```ts fixture=with-vpc
644
+ // Stack 1
645
+ declare const stack1: Stack;
646
+ declare const stack2: Stack;
647
+
648
+ const sg1 = new ec2.SecurityGroup(stack1, 'SG1', {
649
+ allowAllOutbound: false, // if this is `true` then no egress rule will be created
650
+ vpc,
651
+ });
652
+
653
+ // Stack 2
654
+ const sg2 = new ec2.SecurityGroup(stack2, 'SG2', {
655
+ allowAllOutbound: false, // if this is `true` then no egress rule will be created
656
+ vpc,
657
+ });
658
+
659
+
660
+ // `connections.allowFrom` on `sg2` since we want the
661
+ // rules to be created in Stack2
662
+ sg2.connections.allowFrom(sg1, ec2.Port.tcp(3333));
663
+ ```
664
+
665
+ In this case both the Ingress Rule for `sg2` and the Egress Rule for `sg1` will both be created
666
+ in `Stack 2` which avoids the cyclic reference.
667
+
668
+ ## Machine Images (AMIs)
669
+
670
+ AMIs control the OS that gets launched when you start your EC2 instance. The EC2
671
+ library contains constructs to select the AMI you want to use.
672
+
673
+ Depending on the type of AMI, you select it a different way. Here are some
674
+ examples of things you might want to use:
675
+
676
+ [example of creating images](test/example.images.lit.ts)
677
+
678
+ > NOTE: The AMIs selected by `MachineImage.lookup()` will be cached in
679
+ > `cdk.context.json`, so that your AutoScalingGroup instances aren't replaced while
680
+ > you are making unrelated changes to your CDK app.
681
+ >
682
+ > To query for the latest AMI again, remove the relevant cache entry from
683
+ > `cdk.context.json`, or use the `cdk context` command. For more information, see
684
+ > [Runtime Context](https://docs.aws.amazon.com/cdk/latest/guide/context.html) in the CDK
685
+ > developer guide.
686
+ >
687
+ > `MachineImage.genericLinux()`, `MachineImage.genericWindows()` will use `CfnMapping` in
688
+ > an agnostic stack.
689
+
690
+ ## Special VPC configurations
691
+
692
+ ### VPN connections to a VPC
693
+
694
+ Create your VPC with VPN connections by specifying the `vpnConnections` props (keys are construct `id`s):
695
+
696
+ ```ts
697
+ const vpc = new ec2.Vpc(this, 'MyVpc', {
698
+ vpnConnections: {
699
+ dynamic: { // Dynamic routing (BGP)
700
+ ip: '1.2.3.4'
701
+ },
702
+ static: { // Static routing
703
+ ip: '4.5.6.7',
704
+ staticRoutes: [
705
+ '192.168.10.0/24',
706
+ '192.168.20.0/24'
707
+ ]
708
+ }
709
+ }
710
+ });
711
+ ```
712
+
713
+ To create a VPC that can accept VPN connections, set `vpnGateway` to `true`:
714
+
715
+ ```ts
716
+ const vpc = new ec2.Vpc(this, 'MyVpc', {
717
+ vpnGateway: true
718
+ });
719
+ ```
720
+
721
+ VPN connections can then be added:
722
+
723
+ ```ts fixture=with-vpc
724
+ vpc.addVpnConnection('Dynamic', {
725
+ ip: '1.2.3.4'
726
+ });
727
+ ```
728
+
729
+ By default, routes will be propagated on the route tables associated with the private subnets. If no
730
+ private subnets exist, isolated subnets are used. If no isolated subnets exist, public subnets are
731
+ used. Use the `Vpc` property `vpnRoutePropagation` to customize this behavior.
732
+
733
+ VPN connections expose [metrics (cloudwatch.Metric)](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-cloudwatch/README.md) across all tunnels in the account/region and per connection:
734
+
735
+ ```ts fixture=with-vpc
736
+ // Across all tunnels in the account/region
737
+ const allDataOut = ec2.VpnConnection.metricAllTunnelDataOut();
738
+
739
+ // For a specific vpn connection
740
+ const vpnConnection = vpc.addVpnConnection('Dynamic', {
741
+ ip: '1.2.3.4'
742
+ });
743
+ const state = vpnConnection.metricTunnelState();
744
+ ```
745
+
746
+ ### VPC endpoints
747
+
748
+ A VPC endpoint enables you to privately connect your VPC to supported AWS services and VPC endpoint services powered by PrivateLink without requiring an internet gateway, NAT device, VPN connection, or AWS Direct Connect connection. Instances in your VPC do not require public IP addresses to communicate with resources in the service. Traffic between your VPC and the other service does not leave the Amazon network.
749
+
750
+ Endpoints are virtual devices. They are horizontally scaled, redundant, and highly available VPC components that allow communication between instances in your VPC and services without imposing availability risks or bandwidth constraints on your network traffic.
751
+
752
+ [example of setting up VPC endpoints](test/integ.vpc-endpoint.lit.ts)
753
+
754
+ By default, CDK will place a VPC endpoint in one subnet per AZ. If you wish to override the AZs CDK places the VPC endpoint in,
755
+ use the `subnets` parameter as follows:
756
+
757
+ ```ts
758
+ declare const vpc: ec2.Vpc;
759
+
760
+ new ec2.InterfaceVpcEndpoint(this, 'VPC Endpoint', {
761
+ vpc,
762
+ service: new ec2.InterfaceVpcEndpointService('com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc', 443),
763
+ // Choose which availability zones to place the VPC endpoint in, based on
764
+ // available AZs
765
+ subnets: {
766
+ availabilityZones: ['us-east-1a', 'us-east-1c']
767
+ }
768
+ });
769
+ ```
770
+
771
+ Per the [AWS documentation](https://aws.amazon.com/premiumsupport/knowledge-center/interface-endpoint-availability-zone/), not all
772
+ VPC endpoint services are available in all AZs. If you specify the parameter `lookupSupportedAzs`, CDK attempts to discover which
773
+ AZs an endpoint service is available in, and will ensure the VPC endpoint is not placed in a subnet that doesn't match those AZs.
774
+ These AZs will be stored in cdk.context.json.
775
+
776
+ ```ts
777
+ declare const vpc: ec2.Vpc;
778
+
779
+ new ec2.InterfaceVpcEndpoint(this, 'VPC Endpoint', {
780
+ vpc,
781
+ service: new ec2.InterfaceVpcEndpointService('com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc', 443),
782
+ // Choose which availability zones to place the VPC endpoint in, based on
783
+ // available AZs
784
+ lookupSupportedAzs: true
785
+ });
786
+ ```
787
+
788
+ Pre-defined AWS services are defined in the [InterfaceVpcEndpointAwsService](lib/vpc-endpoint.ts) class, and can be used to
789
+ create VPC endpoints without having to configure name, ports, etc. For example, a Keyspaces endpoint can be created for
790
+ use in your VPC:
791
+
792
+ ``` ts
793
+ declare const vpc: ec2.Vpc;
794
+
795
+ new ec2.InterfaceVpcEndpoint(this, 'VPC Endpoint', {
796
+ vpc,
797
+ service: ec2.InterfaceVpcEndpointAwsService.KEYSPACES,
798
+ });
799
+ ```
800
+
801
+ #### Security groups for interface VPC endpoints
802
+
803
+ By default, interface VPC endpoints create a new security group and traffic is **not**
804
+ automatically allowed from the VPC CIDR.
805
+
806
+ Use the `connections` object to allow traffic to flow to the endpoint:
807
+
808
+ ```ts
809
+ declare const myEndpoint: ec2.InterfaceVpcEndpoint;
810
+
811
+ myEndpoint.connections.allowDefaultPortFromAnyIpv4();
812
+ ```
813
+
814
+ Alternatively, existing security groups can be used by specifying the `securityGroups` prop.
815
+
816
+ ### VPC endpoint services
817
+
818
+ A VPC endpoint service enables you to expose a Network Load Balancer(s) as a provider service to consumers, who connect to your service over a VPC endpoint. You can restrict access to your service via allowed principals (anything that extends ArnPrincipal), and require that new connections be manually accepted.
819
+
820
+ ```ts
821
+ declare const networkLoadBalancer1: elbv2.NetworkLoadBalancer;
822
+ declare const networkLoadBalancer2: elbv2.NetworkLoadBalancer;
823
+
824
+ new ec2.VpcEndpointService(this, 'EndpointService', {
825
+ vpcEndpointServiceLoadBalancers: [networkLoadBalancer1, networkLoadBalancer2],
826
+ acceptanceRequired: true,
827
+ allowedPrincipals: [new iam.ArnPrincipal('arn:aws:iam::123456789012:root')]
828
+ });
829
+ ```
830
+
831
+ Endpoint services support private DNS, which makes it easier for clients to connect to your service by automatically setting up DNS in their VPC.
832
+ You can enable private DNS on an endpoint service like so:
833
+
834
+ ```ts
835
+ import { HostedZone, VpcEndpointServiceDomainName } from 'aws-cdk-lib/aws-route53';
836
+ declare const zone: HostedZone;
837
+ declare const vpces: ec2.VpcEndpointService;
838
+
839
+ new VpcEndpointServiceDomainName(this, 'EndpointDomain', {
840
+ endpointService: vpces,
841
+ domainName: 'my-stuff.aws-cdk.dev',
842
+ publicHostedZone: zone,
843
+ });
844
+ ```
845
+
846
+ Note: The domain name must be owned (registered through Route53) by the account the endpoint service is in, or delegated to the account.
847
+ The VpcEndpointServiceDomainName will handle the AWS side of domain verification, the process for which can be found
848
+ [here](https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-services-dns-validation.html)
849
+
850
+ ### Client VPN endpoint
851
+
852
+ AWS Client VPN is a managed client-based VPN service that enables you to securely access your AWS
853
+ resources and resources in your on-premises network. With Client VPN, you can access your resources
854
+ from any location using an OpenVPN-based VPN client.
855
+
856
+ Use the `addClientVpnEndpoint()` method to add a client VPN endpoint to a VPC:
857
+
858
+ ```ts fixture=client-vpn
859
+ vpc.addClientVpnEndpoint('Endpoint', {
860
+ cidr: '10.100.0.0/16',
861
+ serverCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id',
862
+ // Mutual authentication
863
+ clientCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/client-certificate-id',
864
+ // User-based authentication
865
+ userBasedAuthentication: ec2.ClientVpnUserBasedAuthentication.federated(samlProvider),
866
+ });
867
+ ```
868
+
869
+ The endpoint must use at least one [authentication method](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/client-authentication.html):
870
+
871
+ * Mutual authentication with a client certificate
872
+ * User-based authentication (directory or federated)
873
+
874
+ If user-based authentication is used, the [self-service portal URL](https://docs.aws.amazon.com/vpn/latest/clientvpn-user/self-service-portal.html)
875
+ is made available via a CloudFormation output.
876
+
877
+ By default, a new security group is created, and logging is enabled. Moreover, a rule to
878
+ authorize all users to the VPC CIDR is created.
879
+
880
+ To customize authorization rules, set the `authorizeAllUsersToVpcCidr` prop to `false`
881
+ and use `addAuthorizationRule()`:
882
+
883
+ ```ts fixture=client-vpn
884
+ const endpoint = vpc.addClientVpnEndpoint('Endpoint', {
885
+ cidr: '10.100.0.0/16',
886
+ serverCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id',
887
+ userBasedAuthentication: ec2.ClientVpnUserBasedAuthentication.federated(samlProvider),
888
+ authorizeAllUsersToVpcCidr: false,
889
+ });
890
+
891
+ endpoint.addAuthorizationRule('Rule', {
892
+ cidr: '10.0.10.0/32',
893
+ groupId: 'group-id',
894
+ });
895
+ ```
896
+
897
+ Use `addRoute()` to configure network routes:
898
+
899
+ ```ts fixture=client-vpn
900
+ const endpoint = vpc.addClientVpnEndpoint('Endpoint', {
901
+ cidr: '10.100.0.0/16',
902
+ serverCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id',
903
+ userBasedAuthentication: ec2.ClientVpnUserBasedAuthentication.federated(samlProvider),
904
+ });
905
+
906
+ // Client-to-client access
907
+ endpoint.addRoute('Route', {
908
+ cidr: '10.100.0.0/16',
909
+ target: ec2.ClientVpnRouteTarget.local(),
910
+ });
911
+ ```
912
+
913
+ Use the `connections` object of the endpoint to allow traffic to other security groups.
914
+
915
+ ## Instances
916
+
917
+ You can use the `Instance` class to start up a single EC2 instance. For production setups, we recommend
918
+ you use an `AutoScalingGroup` from the `aws-autoscaling` module instead, as AutoScalingGroups will take
919
+ care of restarting your instance if it ever fails.
920
+
921
+ ```ts
922
+ declare const vpc: ec2.Vpc;
923
+ declare const instanceType: ec2.InstanceType;
924
+
925
+ // AWS Linux
926
+ new ec2.Instance(this, 'Instance1', {
927
+ vpc,
928
+ instanceType,
929
+ machineImage: new ec2.AmazonLinuxImage(),
930
+ });
931
+
932
+ // AWS Linux 2
933
+ new ec2.Instance(this, 'Instance2', {
934
+ vpc,
935
+ instanceType,
936
+ machineImage: new ec2.AmazonLinuxImage({
937
+ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
938
+ }),
939
+ });
940
+
941
+ // AWS Linux 2 with kernel 5.x
942
+ new ec2.Instance(this, 'Instance3', {
943
+ vpc,
944
+ instanceType,
945
+ machineImage: new ec2.AmazonLinuxImage({
946
+ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
947
+ kernel: ec2.AmazonLinuxKernel.KERNEL5_X,
948
+ }),
949
+ });
950
+
951
+ // AWS Linux 2022
952
+ new ec2.Instance(this, 'Instance4', {
953
+ vpc,
954
+ instanceType,
955
+ machineImage: new ec2.AmazonLinuxImage({
956
+ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2022,
957
+ }),
958
+ });
959
+
960
+ // Graviton 3 Processor
961
+ new ec2.Instance(this, 'Instance5', {
962
+ vpc,
963
+ instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE),
964
+ machineImage: new ec2.AmazonLinuxImage({
965
+ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
966
+ cpuType: ec2.AmazonLinuxCpuType.ARM_64,
967
+ }),
968
+ });
969
+ ```
970
+
971
+ ### Configuring Instances using CloudFormation Init (cfn-init)
972
+
973
+ CloudFormation Init allows you to configure your instances by writing files to them, installing software
974
+ packages, starting services and running arbitrary commands. By default, if any of the instance setup
975
+ commands throw an error; the deployment will fail and roll back to the previously known good state.
976
+ The following documentation also applies to `AutoScalingGroup`s.
977
+
978
+ For the full set of capabilities of this system, see the documentation for
979
+ [`AWS::CloudFormation::Init`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html).
980
+ Here is an example of applying some configuration to an instance:
981
+
982
+ ```ts
983
+ declare const vpc: ec2.Vpc;
984
+ declare const instanceType: ec2.InstanceType;
985
+ declare const machineImage: ec2.IMachineImage;
986
+
987
+ new ec2.Instance(this, 'Instance', {
988
+ vpc,
989
+ instanceType,
990
+ machineImage,
991
+
992
+ // Showing the most complex setup, if you have simpler requirements
993
+ // you can use `CloudFormationInit.fromElements()`.
994
+ init: ec2.CloudFormationInit.fromConfigSets({
995
+ configSets: {
996
+ // Applies the configs below in this order
997
+ default: ['yumPreinstall', 'config'],
998
+ },
999
+ configs: {
1000
+ yumPreinstall: new ec2.InitConfig([
1001
+ // Install an Amazon Linux package using yum
1002
+ ec2.InitPackage.yum('git'),
1003
+ ]),
1004
+ config: new ec2.InitConfig([
1005
+ // Create a JSON file from tokens (can also create other files)
1006
+ ec2.InitFile.fromObject('/etc/stack.json', {
1007
+ stackId: Stack.of(this).stackId,
1008
+ stackName: Stack.of(this).stackName,
1009
+ region: Stack.of(this).region,
1010
+ }),
1011
+
1012
+ // Create a group and user
1013
+ ec2.InitGroup.fromName('my-group'),
1014
+ ec2.InitUser.fromName('my-user'),
1015
+
1016
+ // Install an RPM from the internet
1017
+ ec2.InitPackage.rpm('http://mirrors.ukfast.co.uk/sites/dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/r/rubygem-git-1.5.0-2.el8.noarch.rpm'),
1018
+ ]),
1019
+ },
1020
+ }),
1021
+ initOptions: {
1022
+ // Optional, which configsets to activate (['default'] by default)
1023
+ configSets: ['default'],
1024
+
1025
+ // Optional, how long the installation is expected to take (5 minutes by default)
1026
+ timeout: Duration.minutes(30),
1027
+
1028
+ // Optional, whether to include the --url argument when running cfn-init and cfn-signal commands (false by default)
1029
+ includeUrl: true,
1030
+
1031
+ // Optional, whether to include the --role argument when running cfn-init and cfn-signal commands (false by default)
1032
+ includeRole: true,
1033
+ },
1034
+ });
1035
+ ```
1036
+
1037
+ You can have services restarted after the init process has made changes to the system.
1038
+ To do that, instantiate an `InitServiceRestartHandle` and pass it to the config elements
1039
+ that need to trigger the restart and the service itself. For example, the following
1040
+ config writes a config file for nginx, extracts an archive to the root directory, and then
1041
+ restarts nginx so that it picks up the new config and files:
1042
+
1043
+ ```ts
1044
+ declare const myBucket: s3.Bucket;
1045
+
1046
+ const handle = new ec2.InitServiceRestartHandle();
1047
+
1048
+ ec2.CloudFormationInit.fromElements(
1049
+ ec2.InitFile.fromString('/etc/nginx/nginx.conf', '...', { serviceRestartHandles: [handle] }),
1050
+ ec2.InitSource.fromS3Object('/var/www/html', myBucket, 'html.zip', { serviceRestartHandles: [handle] }),
1051
+ ec2.InitService.enable('nginx', {
1052
+ serviceRestartHandle: handle,
1053
+ })
1054
+ );
1055
+ ```
1056
+
1057
+ ### Bastion Hosts
1058
+
1059
+ A bastion host functions as an instance used to access servers and resources in a VPC without open up the complete VPC on a network level.
1060
+ You can use bastion hosts using a standard SSH connection targeting port 22 on the host. As an alternative, you can connect the SSH connection
1061
+ feature of AWS Systems Manager Session Manager, which does not need an opened security group. (https://aws.amazon.com/about-aws/whats-new/2019/07/session-manager-launches-tunneling-support-for-ssh-and-scp/)
1062
+
1063
+ A default bastion host for use via SSM can be configured like:
1064
+
1065
+ ```ts fixture=with-vpc
1066
+ const host = new ec2.BastionHostLinux(this, 'BastionHost', { vpc });
1067
+ ```
1068
+
1069
+ If you want to connect from the internet using SSH, you need to place the host into a public subnet. You can then configure allowed source hosts.
1070
+
1071
+ ```ts fixture=with-vpc
1072
+ const host = new ec2.BastionHostLinux(this, 'BastionHost', {
1073
+ vpc,
1074
+ subnetSelection: { subnetType: ec2.SubnetType.PUBLIC },
1075
+ });
1076
+ host.allowSshAccessFrom(ec2.Peer.ipv4('1.2.3.4/32'));
1077
+ ```
1078
+
1079
+ As there are no SSH public keys deployed on this machine, you need to use [EC2 Instance Connect](https://aws.amazon.com/de/blogs/compute/new-using-amazon-ec2-instance-connect-for-ssh-access-to-your-ec2-instances/)
1080
+ with the command `aws ec2-instance-connect send-ssh-public-key` to provide your SSH public key.
1081
+
1082
+ EBS volume for the bastion host can be encrypted like:
1083
+
1084
+ ```ts fixture=with-vpc
1085
+ const host = new ec2.BastionHostLinux(this, 'BastionHost', {
1086
+ vpc,
1087
+ blockDevices: [{
1088
+ deviceName: 'EBSBastionHost',
1089
+ volume: ec2.BlockDeviceVolume.ebs(10, {
1090
+ encrypted: true,
1091
+ }),
1092
+ }],
1093
+ });
1094
+ ```
1095
+
1096
+ ### Block Devices
1097
+
1098
+ To add EBS block device mappings, specify the `blockDevices` property. The following example sets the EBS-backed
1099
+ root device (`/dev/sda1`) size to 50 GiB, and adds another EBS-backed device mapped to `/dev/sdm` that is 100 GiB in
1100
+ size:
1101
+
1102
+ ```ts
1103
+ declare const vpc: ec2.Vpc;
1104
+ declare const instanceType: ec2.InstanceType;
1105
+ declare const machineImage: ec2.IMachineImage;
1106
+
1107
+ new ec2.Instance(this, 'Instance', {
1108
+ vpc,
1109
+ instanceType,
1110
+ machineImage,
1111
+
1112
+ // ...
1113
+
1114
+ blockDevices: [
1115
+ {
1116
+ deviceName: '/dev/sda1',
1117
+ volume: ec2.BlockDeviceVolume.ebs(50),
1118
+ },
1119
+ {
1120
+ deviceName: '/dev/sdm',
1121
+ volume: ec2.BlockDeviceVolume.ebs(100),
1122
+ },
1123
+ ],
1124
+ });
1125
+
1126
+ ```
1127
+
1128
+ It is also possible to encrypt the block devices. In this example we will create an customer managed key encrypted EBS-backed root device:
1129
+
1130
+ ```ts
1131
+ import { Key } from 'aws-cdk-lib/aws-kms';
1132
+
1133
+ declare const vpc: ec2.Vpc;
1134
+ declare const instanceType: ec2.InstanceType;
1135
+ declare const machineImage: ec2.IMachineImage;
1136
+
1137
+ const kmsKey = new Key(this, 'KmsKey')
1138
+
1139
+ new ec2.Instance(this, 'Instance', {
1140
+ vpc,
1141
+ instanceType,
1142
+ machineImage,
1143
+
1144
+ // ...
1145
+
1146
+ blockDevices: [
1147
+ {
1148
+ deviceName: '/dev/sda1',
1149
+ volume: ec2.BlockDeviceVolume.ebs(50, {
1150
+ encrypted: true,
1151
+ kmsKey: kmsKey,
1152
+ }),
1153
+ },
1154
+ ],
1155
+ });
1156
+
1157
+ ```
1158
+
1159
+ ### Volumes
1160
+
1161
+ Whereas a `BlockDeviceVolume` is an EBS volume that is created and destroyed as part of the creation and destruction of a specific instance. A `Volume` is for when you want an EBS volume separate from any particular instance. A `Volume` is an EBS block device that can be attached to, or detached from, any instance at any time. Some types of `Volume`s can also be attached to multiple instances at the same time to allow you to have shared storage between those instances.
1162
+
1163
+ A notable restriction is that a Volume can only be attached to instances in the same availability zone as the Volume itself.
1164
+
1165
+ The following demonstrates how to create a 500 GiB encrypted Volume in the `us-west-2a` availability zone, and give a role the ability to attach that Volume to a specific instance:
1166
+
1167
+ ```ts
1168
+ declare const instance: ec2.Instance;
1169
+ declare const role: iam.Role;
1170
+
1171
+ const volume = new ec2.Volume(this, 'Volume', {
1172
+ availabilityZone: 'us-west-2a',
1173
+ size: Size.gibibytes(500),
1174
+ encrypted: true,
1175
+ });
1176
+
1177
+ volume.grantAttachVolume(role, [instance]);
1178
+ ```
1179
+
1180
+ #### Instances Attaching Volumes to Themselves
1181
+
1182
+ If you need to grant an instance the ability to attach/detach an EBS volume to/from itself, then using `grantAttachVolume` and `grantDetachVolume` as outlined above
1183
+ will lead to an unresolvable circular reference between the instance role and the instance. In this case, use `grantAttachVolumeByResourceTag` and `grantDetachVolumeByResourceTag` as follows:
1184
+
1185
+ ```ts
1186
+ declare const instance: ec2.Instance;
1187
+ declare const volume: ec2.Volume;
1188
+
1189
+ const attachGrant = volume.grantAttachVolumeByResourceTag(instance.grantPrincipal, [instance]);
1190
+ const detachGrant = volume.grantDetachVolumeByResourceTag(instance.grantPrincipal, [instance]);
1191
+ ```
1192
+
1193
+ #### Attaching Volumes
1194
+
1195
+ The Amazon EC2 documentation for
1196
+ [Linux Instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html) and
1197
+ [Windows Instances](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-volumes.html) contains information on how
1198
+ to attach and detach your Volumes to/from instances, and how to format them for use.
1199
+
1200
+ The following is a sample skeleton of EC2 UserData that can be used to attach a Volume to the Linux instance that it is running on:
1201
+
1202
+ ```ts
1203
+ declare const instance: ec2.Instance;
1204
+ declare const volume: ec2.Volume;
1205
+
1206
+ volume.grantAttachVolumeByResourceTag(instance.grantPrincipal, [instance]);
1207
+ const targetDevice = '/dev/xvdz';
1208
+ instance.userData.addCommands(
1209
+ // Retrieve token for accessing EC2 instance metadata (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html)
1210
+ `TOKEN=$(curl -SsfX PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")`,
1211
+ // Retrieve the instance Id of the current EC2 instance
1212
+ `INSTANCE_ID=$(curl -SsfH "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id)`,
1213
+ // Attach the volume to /dev/xvdz
1214
+ `aws --region ${Stack.of(this).region} ec2 attach-volume --volume-id ${volume.volumeId} --instance-id $INSTANCE_ID --device ${targetDevice}`,
1215
+ // Wait until the volume has attached
1216
+ `while ! test -e ${targetDevice}; do sleep 1; done`
1217
+ // The volume will now be mounted. You may have to add additional code to format the volume if it has not been prepared.
1218
+ );
1219
+ ```
1220
+
1221
+ #### Tagging Volumes
1222
+
1223
+ You can configure [tag propagation on volume creation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-propagatetagstovolumeoncreation).
1224
+
1225
+ ```ts
1226
+ declare const vpc: ec2.Vpc;
1227
+ declare const instanceType: ec2.InstanceType;
1228
+ declare const machineImage: ec2.IMachineImage;
1229
+
1230
+ new ec2.Instance(this, 'Instance', {
1231
+ vpc,
1232
+ machineImage,
1233
+ instanceType,
1234
+ propagateTagsToVolumeOnCreation: true,
1235
+ });
1236
+ ```
1237
+
1238
+ ### Configuring Instance Metadata Service (IMDS)
1239
+
1240
+ #### Toggling IMDSv1
1241
+
1242
+ You can configure [EC2 Instance Metadata Service](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) options to either
1243
+ allow both IMDSv1 and IMDSv2 or enforce IMDSv2 when interacting with the IMDS.
1244
+
1245
+ To do this for a single `Instance`, you can use the `requireImdsv2` property.
1246
+ The example below demonstrates IMDSv2 being required on a single `Instance`:
1247
+
1248
+ ```ts
1249
+ declare const vpc: ec2.Vpc;
1250
+ declare const instanceType: ec2.InstanceType;
1251
+ declare const machineImage: ec2.IMachineImage;
1252
+
1253
+ new ec2.Instance(this, 'Instance', {
1254
+ vpc,
1255
+ instanceType,
1256
+ machineImage,
1257
+
1258
+ // ...
1259
+
1260
+ requireImdsv2: true,
1261
+ });
1262
+ ```
1263
+
1264
+ You can also use the either the `InstanceRequireImdsv2Aspect` for EC2 instances or the `LaunchTemplateRequireImdsv2Aspect` for EC2 launch templates
1265
+ to apply the operation to multiple instances or launch templates, respectively.
1266
+
1267
+ The following example demonstrates how to use the `InstanceRequireImdsv2Aspect` to require IMDSv2 for all EC2 instances in a stack:
1268
+
1269
+ ```ts
1270
+ const aspect = new ec2.InstanceRequireImdsv2Aspect();
1271
+ Aspects.of(this).add(aspect);
1272
+ ```
1273
+
1274
+ ## VPC Flow Logs
1275
+
1276
+ VPC Flow Logs is a feature that enables you to capture information about the IP traffic going to and from network interfaces in your VPC. Flow log data can be published to Amazon CloudWatch Logs and Amazon S3. After you've created a flow log, you can retrieve and view its data in the chosen destination. (<https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html>).
1277
+
1278
+ By default, a flow log will be created with CloudWatch Logs as the destination.
1279
+
1280
+ You can create a flow log like this:
1281
+
1282
+ ```ts
1283
+ declare const vpc: ec2.Vpc;
1284
+
1285
+ new ec2.FlowLog(this, 'FlowLog', {
1286
+ resourceType: ec2.FlowLogResourceType.fromVpc(vpc)
1287
+ })
1288
+ ```
1289
+
1290
+ Or you can add a Flow Log to a VPC by using the addFlowLog method like this:
1291
+
1292
+ ```ts
1293
+ const vpc = new ec2.Vpc(this, 'Vpc');
1294
+
1295
+ vpc.addFlowLog('FlowLog');
1296
+ ```
1297
+
1298
+ You can also add multiple flow logs with different destinations.
1299
+
1300
+ ```ts
1301
+ const vpc = new ec2.Vpc(this, 'Vpc');
1302
+
1303
+ vpc.addFlowLog('FlowLogS3', {
1304
+ destination: ec2.FlowLogDestination.toS3()
1305
+ });
1306
+
1307
+ vpc.addFlowLog('FlowLogCloudWatch', {
1308
+ trafficType: ec2.FlowLogTrafficType.REJECT
1309
+ });
1310
+ ```
1311
+
1312
+ By default, the CDK will create the necessary resources for the destination. For the CloudWatch Logs destination
1313
+ it will create a CloudWatch Logs Log Group as well as the IAM role with the necessary permissions to publish to
1314
+ the log group. In the case of an S3 destination, it will create the S3 bucket.
1315
+
1316
+ If you want to customize any of the destination resources you can provide your own as part of the `destination`.
1317
+
1318
+ *CloudWatch Logs*
1319
+
1320
+ ```ts
1321
+ declare const vpc: ec2.Vpc;
1322
+
1323
+ const logGroup = new logs.LogGroup(this, 'MyCustomLogGroup');
1324
+
1325
+ const role = new iam.Role(this, 'MyCustomRole', {
1326
+ assumedBy: new iam.ServicePrincipal('vpc-flow-logs.amazonaws.com')
1327
+ });
1328
+
1329
+ new ec2.FlowLog(this, 'FlowLog', {
1330
+ resourceType: ec2.FlowLogResourceType.fromVpc(vpc),
1331
+ destination: ec2.FlowLogDestination.toCloudWatchLogs(logGroup, role)
1332
+ });
1333
+ ```
1334
+
1335
+ *S3*
1336
+
1337
+ ```ts
1338
+ declare const vpc: ec2.Vpc;
1339
+
1340
+ const bucket = new s3.Bucket(this, 'MyCustomBucket');
1341
+
1342
+ new ec2.FlowLog(this, 'FlowLog', {
1343
+ resourceType: ec2.FlowLogResourceType.fromVpc(vpc),
1344
+ destination: ec2.FlowLogDestination.toS3(bucket)
1345
+ });
1346
+
1347
+ new ec2.FlowLog(this, 'FlowLogWithKeyPrefix', {
1348
+ resourceType: ec2.FlowLogResourceType.fromVpc(vpc),
1349
+ destination: ec2.FlowLogDestination.toS3(bucket, 'prefix/')
1350
+ });
1351
+ ```
1352
+
1353
+ When the S3 destination is configured, AWS will automatically create an S3 bucket policy
1354
+ that allows the service to write logs to the bucket. This makes it impossible to later update
1355
+ that bucket policy. To have CDK create the bucket policy so that future updates can be made,
1356
+ the `@aws-cdk/aws-s3:createDefaultLoggingPolicy` [feature flag](https://docs.aws.amazon.com/cdk/v2/guide/featureflags.html) can be used. This can be set
1357
+ in the `cdk.json` file.
1358
+
1359
+ ```json
1360
+ {
1361
+ "context": {
1362
+ "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true
1363
+ }
1364
+ }
1365
+ ```
1366
+
1367
+ ## User Data
1368
+
1369
+ User data enables you to run a script when your instances start up. In order to configure these scripts you can add commands directly to the script
1370
+ or you can use the UserData's convenience functions to aid in the creation of your script.
1371
+
1372
+ A user data could be configured to run a script found in an asset through the following:
1373
+
1374
+ ```ts
1375
+ import { Asset } from 'aws-cdk-lib/aws-s3-assets';
1376
+
1377
+ declare const instance: ec2.Instance;
1378
+
1379
+ const asset = new Asset(this, 'Asset', {
1380
+ path: './configure.sh'
1381
+ });
1382
+
1383
+ const localPath = instance.userData.addS3DownloadCommand({
1384
+ bucket:asset.bucket,
1385
+ bucketKey:asset.s3ObjectKey,
1386
+ region: 'us-east-1', // Optional
1387
+ });
1388
+ instance.userData.addExecuteFileCommand({
1389
+ filePath:localPath,
1390
+ arguments: '--verbose -y'
1391
+ });
1392
+ asset.grantRead(instance.role);
1393
+ ```
1394
+
1395
+ ### Multipart user data
1396
+
1397
+ In addition, to above the `MultipartUserData` can be used to change instance startup behavior. Multipart user data are composed
1398
+ from separate parts forming archive. The most common parts are scripts executed during instance set-up. However, there are other
1399
+ kinds, too.
1400
+
1401
+ The advantage of multipart archive is in flexibility when it's needed to add additional parts or to use specialized parts to
1402
+ fine tune instance startup. Some services (like AWS Batch) support only `MultipartUserData`.
1403
+
1404
+ The parts can be executed at different moment of instance start-up and can serve a different purpose. This is controlled by `contentType` property.
1405
+ For common scripts, `text/x-shellscript; charset="utf-8"` can be used as content type.
1406
+
1407
+ In order to create archive the `MultipartUserData` has to be instantiated. Than, user can add parts to multipart archive using `addPart`. The `MultipartBody` contains methods supporting creation of body parts.
1408
+
1409
+ If the very custom part is required, it can be created using `MultipartUserData.fromRawBody`, in this case full control over content type,
1410
+ transfer encoding, and body properties is given to the user.
1411
+
1412
+ Below is an example for creating multipart user data with single body part responsible for installing `awscli` and configuring maximum size
1413
+ of storage used by Docker containers:
1414
+
1415
+ ```ts
1416
+ const bootHookConf = ec2.UserData.forLinux();
1417
+ bootHookConf.addCommands('cloud-init-per once docker_options echo \'OPTIONS="${OPTIONS} --storage-opt dm.basesize=40G"\' >> /etc/sysconfig/docker');
1418
+
1419
+ const setupCommands = ec2.UserData.forLinux();
1420
+ setupCommands.addCommands('sudo yum install awscli && echo Packages installed らと > /var/tmp/setup');
1421
+
1422
+ const multipartUserData = new ec2.MultipartUserData();
1423
+ // The docker has to be configured at early stage, so content type is overridden to boothook
1424
+ multipartUserData.addPart(ec2.MultipartBody.fromUserData(bootHookConf, 'text/cloud-boothook; charset="us-ascii"'));
1425
+ // Execute the rest of setup
1426
+ multipartUserData.addPart(ec2.MultipartBody.fromUserData(setupCommands));
1427
+
1428
+ new ec2.LaunchTemplate(this, '', {
1429
+ userData: multipartUserData,
1430
+ blockDevices: [
1431
+ // Block device configuration rest
1432
+ ]
1433
+ });
1434
+ ```
1435
+
1436
+ For more information see
1437
+ [Specifying Multiple User Data Blocks Using a MIME Multi Part Archive](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/bootstrap_container_instance.html#multi-part_user_data)
1438
+
1439
+ #### Using add*Command on MultipartUserData
1440
+
1441
+ To use the `add*Command` methods, that are inherited from the `UserData` interface, on `MultipartUserData` you must add a part
1442
+ to the `MultipartUserData` and designate it as the reciever for these methods. This is accomplished by using the `addUserDataPart()`
1443
+ method on `MultipartUserData` with the `makeDefault` argument set to `true`:
1444
+
1445
+ ```ts
1446
+ const multipartUserData = new ec2.MultipartUserData();
1447
+ const commandsUserData = ec2.UserData.forLinux();
1448
+ multipartUserData.addUserDataPart(commandsUserData, ec2.MultipartBody.SHELL_SCRIPT, true);
1449
+
1450
+ // Adding commands to the multipartUserData adds them to commandsUserData, and vice-versa.
1451
+ multipartUserData.addCommands('touch /root/multi.txt');
1452
+ commandsUserData.addCommands('touch /root/userdata.txt');
1453
+ ```
1454
+
1455
+ When used on an EC2 instance, the above `multipartUserData` will create both `multi.txt` and `userdata.txt` in `/root`.
1456
+
1457
+ ## Importing existing subnet
1458
+
1459
+ To import an existing Subnet, call `Subnet.fromSubnetAttributes()` or
1460
+ `Subnet.fromSubnetId()`. Only if you supply the subnet's Availability Zone
1461
+ and Route Table Ids when calling `Subnet.fromSubnetAttributes()` will you be
1462
+ able to use the CDK features that use these values (such as selecting one
1463
+ subnet per AZ).
1464
+
1465
+ Importing an existing subnet looks like this:
1466
+
1467
+ ```ts
1468
+ // Supply all properties
1469
+ const subnet1 = ec2.Subnet.fromSubnetAttributes(this, 'SubnetFromAttributes', {
1470
+ subnetId: 's-1234',
1471
+ availabilityZone: 'pub-az-4465',
1472
+ routeTableId: 'rt-145'
1473
+ });
1474
+
1475
+ // Supply only subnet id
1476
+ const subnet2 = ec2.Subnet.fromSubnetId(this, 'SubnetFromId', 's-1234');
1477
+ ```
1478
+
1479
+ ## Launch Templates
1480
+
1481
+ A Launch Template is a standardized template that contains the configuration information to launch an instance.
1482
+ They can be used when launching instances on their own, through Amazon EC2 Auto Scaling, EC2 Fleet, and Spot Fleet.
1483
+ Launch templates enable you to store launch parameters so that you do not have to specify them every time you launch
1484
+ an instance. For information on Launch Templates please see the
1485
+ [official documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html).
1486
+
1487
+ The following demonstrates how to create a launch template with an Amazon Machine Image, and security group.
1488
+
1489
+ ```ts
1490
+ declare const vpc: ec2.Vpc;
1491
+
1492
+ const template = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
1493
+ machineImage: ec2.MachineImage.latestAmazonLinux(),
1494
+ securityGroup: new ec2.SecurityGroup(this, 'LaunchTemplateSG', {
1495
+ vpc: vpc,
1496
+ }),
1497
+ });
1498
+ ```
1499
+
1500
+ ## Detailed Monitoring
1501
+
1502
+ The following demonstrates how to enable [Detailed Monitoring](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch-new.html) for an EC2 instance. Keep in mind that Detailed Monitoring results in [additional charges](http://aws.amazon.com/cloudwatch/pricing/).
1503
+
1504
+ ```ts
1505
+ declare const vpc: ec2.Vpc;
1506
+ declare const instanceType: ec2.InstanceType;
1507
+
1508
+ new ec2.Instance(this, 'Instance1', {
1509
+ vpc,
1510
+ instanceType,
1511
+ machineImage: new ec2.AmazonLinuxImage(),
1512
+ detailedMonitoring: true,
1513
+ });
1514
+ ```