1+ from aws_cdk import (
2+ Stack ,
3+ aws_autoscaling as autoscaling ,
4+ aws_ec2 as ec2 ,
5+ aws_ecs as ecs ,
6+ aws_iam as iam ,
7+ )
8+ from constructs import Construct
9+
10+ # change your ARNs here
11+ arn1 = "arn:aws:s3:::yourBucket/dummy-input.conf"
12+ arn2 = "arn:aws:s3:::yourBucket/dummy-filter.conf"
13+ arn3 = "arn:aws:s3:::yourBucket/dummy-parser.conf"
14+ arn4 = "arn:aws:s3:::yourBucket/dummy-s3-output.conf"
15+
16+ class IntegTestStack (Stack ):
17+
18+ def __init__ (self , scope : Construct , construct_id : str , ** kwargs ) -> None :
19+ super ().__init__ (scope , construct_id , ** kwargs )
20+
21+ vpc = ec2 .Vpc (self , "VPC" )
22+
23+ cluster = ecs .Cluster (self , "Cluster" , vpc = vpc )
24+
25+ auto_scaling_group = autoscaling .AutoScalingGroup (self , "ASG" ,
26+ vpc = vpc ,
27+ instance_type = ec2 .InstanceType ("t2.micro" ),
28+ machine_image = ecs .EcsOptimizedImage .amazon_linux2 (),
29+ )
30+
31+ capacity_provider = ecs .AsgCapacityProvider (self ,
32+ "AsgCapacityProvider" ,
33+ auto_scaling_group = auto_scaling_group
34+ )
35+
36+ cluster .add_asg_capacity_provider (capacity_provider )
37+
38+ task_definition = ecs .Ec2TaskDefinition (self , "TaskDef" )
39+
40+ task_definition .add_container ("log_router" ,
41+ image = ecs .ContainerImage .from_registry ("public.ecr.aws/aws-observability/aws-for-fluent-bit:init-latest" ),
42+ memory_reservation_mib = 50 ,
43+ logging = ecs .LogDrivers .aws_logs (
44+ stream_prefix = "Firelens-log" ,
45+ ),
46+ environment = {
47+ "aws_fluent_bit_init_s3_1" : arn1 ,
48+ "aws_fluent_bit_init_s3_2" : arn2 ,
49+ "aws_fluent_bit_init_s3_3" : arn3 ,
50+ "aws_fluent_bit_init_s3_4" : arn4 ,
51+ },
52+ )
53+
54+ task_definition .task_role .add_managed_policy (
55+ iam .ManagedPolicy .from_aws_managed_policy_name ("AmazonS3FullAccess" )
56+ )
57+
58+ task_definition .task_role .add_managed_policy (
59+ iam .ManagedPolicy .from_aws_managed_policy_name ("AmazonSSMFullAccess" )
60+ )
61+
62+ task_definition .task_role .add_managed_policy (
63+ iam .ManagedPolicy .from_aws_managed_policy_name ("CloudWatchFullAccess" )
64+ )
65+
66+ ecs_service = ecs .Ec2Service (self , "Service" ,
67+ cluster = cluster ,
68+ task_definition = task_definition ,
69+ enable_execute_command = True
70+ )
0 commit comments