|
6 | 6 | from aws_cdk import ( |
7 | 7 | # Duration, |
8 | 8 | Stack, |
| 9 | + aws_s3 as s3, |
9 | 10 | aws_apigateway as apigateway, |
10 | 11 | aws_dynamodb as dynamodb, |
| 12 | + aws_cloudfront as cf, |
11 | 13 | aws_iam as iam, |
12 | 14 | aws_lambda as _lambda, |
| 15 | + aws_lambda_nodejs as _jslambda, |
13 | 16 | aws_sns as sns, |
14 | 17 | aws_stepfunctions as sfn, |
15 | 18 | aws_pipes as pipes, |
@@ -294,6 +297,28 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: |
294 | 297 | role=state_machine_role, |
295 | 298 | ) |
296 | 299 |
|
| 300 | + webapp_bucket = s3.Bucket( |
| 301 | + self, |
| 302 | + "WebAppBucket", |
| 303 | + auto_delete_objects=True, |
| 304 | + removal_policy=aws_cdk.RemovalPolicy.DESTROY, |
| 305 | + ) |
| 306 | + origin_access_identity = cf.OriginAccessIdentity(self, "OriginAccessIdentity") |
| 307 | + webapp_bucket.grant_read(origin_access_identity) |
| 308 | + custom_resource_lambda = _lambda.Function( |
| 309 | + self, |
| 310 | + "WebsiteDeployFunction", |
| 311 | + runtime=_lambda.Runtime.NODEJS_LATEST, |
| 312 | + handler="index.handler", |
| 313 | + memory_size=1024, |
| 314 | + ephemeral_storage_size=aws_cdk.Size.gibibytes(8), |
| 315 | + code=_lambda.Code.from_asset("./website_deploy"), |
| 316 | + timeout=aws_cdk.Duration.seconds(300), |
| 317 | + # TODO |
| 318 | + environment={}, |
| 319 | + ) |
| 320 | + webapp_bucket.grant_write(custom_resource_lambda) |
| 321 | + |
297 | 322 | @staticmethod |
298 | 323 | def read_policy_file(file_path: str) -> dict: |
299 | 324 | """Reads a JSON policy file and returns it as a dictionary.""" |
|
0 commit comments