def __init__()

in 4-serverless-cicd-stack/visit-service-cicd/serverless_lambda/serverless_lambda_stack.py [0:0]


    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # The code that defines your stack goes here

        lambda_policies = [iam.PolicyStatement(
            actions=[ "logs:CreateLogStream", "logs:PutLogEvents", "logs:CreateLogGroup"],
            effect=iam.Effect.ALLOW,
            resources=["arn:aws:logs:" + core.Aws.REGION + ":" + core.Aws.ACCOUNT_ID + ":*"]
        ), iam.PolicyStatement(
            actions=[ "dynamodb:*"],
            effect=iam.Effect.ALLOW,
            resources=["arn:aws:dynamodb:" + core.Aws.REGION + ":" + core.Aws.ACCOUNT_ID + ":*"]
        )]


        table = _dynamodb.Table(self, 'VisitTable',
            partition_key={ 'name': 'id', 'type': _dynamodb.AttributeType.STRING },
            removal_policy=core.RemovalPolicy.DESTROY,
            read_capacity=5,
            write_capacity=5,
        )

        # Modify the config.js with CF custome resource

        modify_policy = [iam.PolicyStatement(
                actions=[ "dynamodb:*"],
                effect=iam.Effect.ALLOW,
                resources=["arn:aws:dynamodb:" + core.Aws.REGION + ":" + core.Aws.ACCOUNT_ID + ":*"]
            )]

        resource = _cfn.CustomResource(self, "VisitDataImportCustomResource",
            provider=_cfn.CustomResourceProvider.lambda_(
                _lambda.SingletonFunction(
                    self, "CustomResourceSingleton",
                    uuid="f7d4f730-4ee1-11e8-9c2d-fa7ae01bbebc",
                    code=self.custom_resource,
                    handler="index.handler",
                    timeout=core.Duration.seconds(300),
                    runtime=_lambda.Runtime.PYTHON_3_7,
                    initial_policy=modify_policy
                )
            ),
            properties={"DynamoDBTable": table.table_name}
        )

        base_lambda = _lambda.Function(self,'ApiPetclinicVisitLambda',
            handler='org.springframework.samples.petclinic.visits.StreamLambdaHandler::handleRequest',
            runtime=_lambda.Runtime.JAVA_8,
            code=self.lambda_code,
            memory_size=1024,
            timeout=core.Duration.seconds(300),
            initial_policy=lambda_policies,
            environment={"DYNAMODB_TABLE_NAME":table.table_name, "SERVER_SERVLET_CONTEXT_PATH":"/api/visit"}
        )
       

        version = base_lambda.add_version(str(round(time.time())))

        alias = _lambda.Alias(self, 'ApiPetclinicVisitLambdaAlias',
          alias_name='Prod',
          version=version,
          provisioned_concurrent_executions=5
        )

        _deploy.LambdaDeploymentGroup(self, 'ApiPetclinicVisitDeploymentGroup',
          alias=alias,
          deployment_config=_deploy.LambdaDeploymentConfig.LINEAR_10_PERCENT_EVERY_1_MINUTE
        )