From a8f06916d3d701f396ab6969057610975fbb01f3 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Tue, 2 Jul 2024 14:03:21 +0200 Subject: [PATCH 1/2] Use poetry & pyright in aws-py-fargate --- aws-py-fargate/Pulumi.yaml | 4 ++-- aws-py-fargate/pyproject.toml | 12 ++++++++++++ aws-py-fargate/requirements.txt | 2 -- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 aws-py-fargate/pyproject.toml delete mode 100644 aws-py-fargate/requirements.txt diff --git a/aws-py-fargate/Pulumi.yaml b/aws-py-fargate/Pulumi.yaml index 87ef0e7ed..c9e249700 100644 --- a/aws-py-fargate/Pulumi.yaml +++ b/aws-py-fargate/Pulumi.yaml @@ -3,5 +3,5 @@ description: A container running in AWS ECS Fargate, using Python infrastructure runtime: name: python options: - virtualenv: venv - + toolchain: poetry + typechecker: pyright diff --git a/aws-py-fargate/pyproject.toml b/aws-py-fargate/pyproject.toml new file mode 100644 index 000000000..19ae2a440 --- /dev/null +++ b/aws-py-fargate/pyproject.toml @@ -0,0 +1,12 @@ +[tool.poetry] +package-mode = false + +[tool.poetry.dependencies] +python = "^3.10" +pulumi = ">=3.122.0,<4.0.0" +pulumi-aws = ">=6.42.1,<7.0.0" +pyright = ">=1.1.369,<2.0.0" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/aws-py-fargate/requirements.txt b/aws-py-fargate/requirements.txt deleted file mode 100644 index 01505defd..000000000 --- a/aws-py-fargate/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pulumi>=3.5.1,<4.0.0 -pulumi-aws>=6.0.2,<7.0.0 From 84ddc8bdd4244206831a97bf4a89d5b20b55cd28 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Tue, 2 Jul 2024 14:03:44 +0200 Subject: [PATCH 2/2] Use dictionary literals in aws-py-fargate --- aws-py-fargate/__main__.py | 62 ++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/aws-py-fargate/__main__.py b/aws-py-fargate/__main__.py index 635cbccc1..421380678 100644 --- a/aws-py-fargate/__main__.py +++ b/aws-py-fargate/__main__.py @@ -8,30 +8,28 @@ # Read back the default VPC and public subnets, which we will use. default_vpc = aws.ec2.get_vpc(default=True) default_vpc_subnets = aws.ec2.get_subnets( - filters = [ - aws.ec2.GetSubnetsFilterArgs( - name='vpc-id', - values=[default_vpc.id], - ), - ], + filters = [{ + 'name': 'vpc-id', + 'values': [default_vpc.id], + }], ) # Create a SecurityGroup that permits HTTP ingress and unrestricted egress. group = aws.ec2.SecurityGroup('web-secgrp', vpc_id=default_vpc.id, description='Enable HTTP access', - ingress=[aws.ec2.SecurityGroupIngressArgs( - protocol='tcp', - from_port=80, - to_port=80, - cidr_blocks=['0.0.0.0/0'], - )], - egress=[aws.ec2.SecurityGroupEgressArgs( - protocol='-1', - from_port=0, - to_port=0, - cidr_blocks=['0.0.0.0/0'], - )], + ingress=[{ + 'protocol': 'tcp', + 'from_port': 80, + 'to_port': 80, + 'cidr_blocks': ['0.0.0.0/0'], + }], + egress=[{ + 'protocol': '-1', + 'from_port': 0, + 'to_port': 0, + 'cidr_blocks': ['0.0.0.0/0'], + }], ) # Create a load balancer to listen for HTTP traffic on port 80. @@ -50,10 +48,10 @@ wl = aws.lb.Listener('web', load_balancer_arn=alb.arn, port=80, - default_actions=[aws.lb.ListenerDefaultActionArgs( - type='forward', - target_group_arn=atg.arn, - )], + default_actions=[{ + 'type': 'forward', + 'target_group_arn': atg.arn, + }], ) # Create an IAM role that can be used by our service's task. @@ -100,16 +98,16 @@ desired_count=3, launch_type='FARGATE', task_definition=task_definition.arn, - network_configuration=aws.ecs.ServiceNetworkConfigurationArgs( - assign_public_ip=True, - subnets=default_vpc_subnets.ids, - security_groups=[group.id], - ), - load_balancers=[aws.ecs.ServiceLoadBalancerArgs( - target_group_arn=atg.arn, - container_name='my-app', - container_port=80, - )], + network_configuration={ + 'assign_public_ip': True, + 'subnets': default_vpc_subnets.ids, + 'security_groups': [group.id], + }, + load_balancers=[{ + 'target_group_arn': atg.arn, + 'container_name': 'my-app', + 'container_port': 80, + }], opts=ResourceOptions(depends_on=[wl]), )