1
- from aws_cdk import core as cdk
2
- from aws_cdk import aws_lambda
3
- from aws_cdk import aws_iam as iam
4
- from aws_cdk import aws_logs as logs
5
-
6
- # For consistency with other languages, `cdk` is the preferred import name for
7
- # the CDK's core module. The following line also imports it as `core` for use
8
- # with examples from the CDK Developer's Guide, which are in the process of
9
- # being updated to use `cdk`. You may delete this import if you don't need it.
10
- from aws_cdk import core
11
-
12
-
13
- class LambdaSnsSmsCdkStack (cdk .Stack ):
14
-
15
- def __init__ (self , scope : cdk .Construct , construct_id : str , ** kwargs ) -> None :
1
+ from aws_cdk import (
2
+ Stack ,
3
+ RemovalPolicy ,
4
+ Duration ,
5
+ CfnParameter ,
6
+ CfnOutput ,
7
+ aws_lambda ,
8
+ aws_iam as iam ,
9
+ aws_logs as logs
10
+ )
11
+ from constructs import Construct
12
+
13
+
14
+ class LambdaSnsSmsCdkStack (Stack ):
15
+
16
+ def __init__ (self , scope : Construct , construct_id : str , ** kwargs ) -> None :
16
17
super ().__init__ (scope , construct_id , ** kwargs )
17
18
18
- phoneNumber = core . CfnParameter (self , "phoneNumber" , type = "String" ,
19
+ phoneNumber = CfnParameter (self , "phoneNumber" , type = "String" ,
19
20
description = "Recipient phone number" )
20
- tenDLC = core . CfnParameter (self , "tenDLC" , type = "String" ,
21
+ tenDLC = CfnParameter (self , "tenDLC" , type = "String" ,
21
22
description = "10DLC origination number" )
22
23
23
24
# We create a log group so it will be gracefully cleaned up on a destroy event. By default
24
25
# logs never expire and won't be removed.
25
26
lambdaLogGroup = logs .LogGroup (self ,
26
27
'SMSPublisherFunctionLogGroup' ,
27
28
log_group_name = '/aws/lambda/SMSPublisherFunction' ,
28
- removal_policy = core . RemovalPolicy .DESTROY ,
29
+ removal_policy = RemovalPolicy .DESTROY ,
29
30
retention = logs .RetentionDays .FIVE_DAYS ,
30
31
)
31
32
@@ -35,7 +36,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
35
36
function_name = 'SMSPublisherFunction' ,
36
37
handler = 'app.handler' ,
37
38
runtime = aws_lambda .Runtime .NODEJS_12_X ,
38
- timeout = core . Duration .seconds (3 ),
39
+ timeout = Duration .seconds (3 ),
39
40
memory_size = 128 ,
40
41
environment = {'phoneNumber' : phoneNumber .value_as_string ,
41
42
'tenDLC' : tenDLC .value_as_string },
@@ -55,7 +56,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
55
56
# Make sure the log group is created prior to the function so CDK doesn't create a new one
56
57
SMSPublisherFunction .node .add_dependency (lambdaLogGroup )
57
58
58
- core . CfnOutput (self ,
59
+ CfnOutput (self ,
59
60
'SMSPublisherFunctionName' ,
60
61
description = 'SMSPublisherFunction function name' ,
61
62
value = SMSPublisherFunction .function_name
0 commit comments