Skip to content

Commit

Permalink
style: Add some ignore attr-defined lines
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundmiller committed Aug 5, 2024
1 parent 69ab75a commit f505310
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 66 deletions.
2 changes: 1 addition & 1 deletion pulumi/AWSMegatests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
bucket = s3.Bucket("my-bucket")

# Export the name of the bucket
pulumi.export("bucket_name", bucket.id)
pulumi.export("bucket_name", bucket.id) # type: ignore[attr-defined]
147 changes: 87 additions & 60 deletions pulumi/analytics/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,116 @@
import pulumi_aws as aws

# Create the VPC
vpc = aws.ec2.Vpc("plausible-vpc",
vpc = aws.ec2.Vpc(
"plausible-vpc",
cidr_block="10.0.0.0/16",
enable_dns_support=True,
enable_dns_hostnames=True)
enable_dns_hostnames=True,
)

# Create subnets
subnet = aws.ec2.Subnet("plausible-subnet",
vpc_id=vpc.id,
cidr_block="10.0.1.0/24")
subnet = aws.ec2.Subnet("plausible-subnet", vpc_id=vpc.id, cidr_block="10.0.1.0/24")

# Create an internet gateway
gateway = aws.ec2.InternetGateway("plausible-igw", vpc_id=vpc.id)

# Create a route table
route_table = aws.ec2.RouteTable("plausible-route-table",
route_table = aws.ec2.RouteTable(
"plausible-route-table",
vpc_id=vpc.id,
routes=[{
"cidr_block": "0.0.0.0/0",
"gateway_id": gateway.id,
}])
route_table_association = aws.ec2.RouteTableAssociation("plausible-route-table-association",
routes=[
{
"cidr_block": "0.0.0.0/0",
"gateway_id": gateway.id,
}
],
)
route_table_association = aws.ec2.RouteTableAssociation(
"plausible-route-table-association",
subnet_id=subnet.id,
route_table_id=route_table.id)
route_table_id=route_table.id,
)

# Create a security group
security_group = aws.ec2.SecurityGroup("plausible-sg",
security_group = aws.ec2.SecurityGroup(
"plausible-sg",
vpc_id=vpc.id,
description="Allow web traffic to Plausible",
ingress=[{
"protocol": "tcp",
"from_port": 80,
"to_port": 80,
"cidr_blocks": ["0.0.0.0/0"],
},
{
"protocol": "tcp",
"from_port": 443,
"to_port": 443,
"cidr_blocks": ["0.0.0.0/0"],
}],
egress=[{
"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"],
},
{
"protocol": "tcp",
"from_port": 443,
"to_port": 443,
"cidr_blocks": ["0.0.0.0/0"],
},
],
egress=[
{
"protocol": "-1",
"from_port": 0,
"to_port": 0,
"cidr_blocks": ["0.0.0.0/0"],
}
],
)

# Create the RDS PostgreSQL database
rds_db = aws.rds.Instance("plausible-db",
rds_db = aws.rds.Instance(
"plausible-db",
engine="postgres",
instance_class="db.t3.micro",
allocated_storage=20,
db_subnet_group_name=aws.rds.SubnetGroup("plausible-db-subnet-group",
db_subnet_group_name=aws.rds.SubnetGroup(
"plausible-db-subnet-group",
subnet_ids=[subnet.id],
name="plausible-db-subnet-group"
name="plausible-db-subnet-group",
).name,
vpc_security_group_ids=[security_group.id],
username="admin",
password="password",
skip_final_snapshot=True)
skip_final_snapshot=True,
)

# Create an ECS cluster
cluster = aws.ecs.Cluster("plausible-cluster")

# Create a load balancer
alb = aws.lb.LoadBalancer("plausible-lb",
security_groups=[security_group.id],
subnets=[subnet.id])
alb = aws.lb.LoadBalancer(
"plausible-lb", security_groups=[security_group.id], subnets=[subnet.id]
)

target_group = aws.lb.TargetGroup("plausible-tg",
port=80,
protocol="HTTP",
vpc_id=vpc.id,
target_type="ip")
target_group = aws.lb.TargetGroup(
"plausible-tg", port=80, protocol="HTTP", vpc_id=vpc.id, target_type="ip"
)

listener = aws.lb.Listener("plausible-listener",
listener = aws.lb.Listener(
"plausible-listener",
load_balancer_arn=alb.arn,
port=80,
default_actions=[{
"type": "forward",
"target_group_arn": target_group.arn,
}])
default_actions=[
{
"type": "forward",
"target_group_arn": target_group.arn,
}
],
)

# Create ECS Task Definition
task_definition = aws.ecs.TaskDefinition("plausible-task",
task_definition = aws.ecs.TaskDefinition(
"plausible-task",
family="plausible",
cpu="256",
memory="512",
network_mode="awsvpc",
requires_compatibilities=["FARGATE"],
execution_role_arn=aws.iam.Role("ecsTaskExecutionRole",
execution_role_arn=aws.iam.Role(
"ecsTaskExecutionRole",
assume_role_policy="""{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -105,9 +123,12 @@
"Action": "sts:AssumeRole"
}
]
}"""
}""",
).arn,
container_definitions=pulumi.Output.all(rds_db.endpoint).apply(lambda db_endpoint: f"""[{
container_definitions=pulumi.Output.all( # type: ignore[attr-defined]
rds_db.endpoint
).apply(
lambda db_endpoint: f"""[{
"name": "plausible",
"image": "plausible/analytics",
"cpu": 256,
Expand All @@ -122,10 +143,13 @@
"environment": [
{{"name": "DATABASE_URL", "value": "postgres://admin:password@{db_endpoint}:5432/plausible"}}
]
}]"""))
}]"""
),
)

# Create ECS service
ecs_service = aws.ecs.Service("plausible-service",
ecs_service = aws.ecs.Service(
"plausible-service",
cluster=cluster.arn,
task_definition=task_definition.arn,
desired_count=1,
Expand All @@ -134,11 +158,14 @@
"subnets": [subnet.id],
"security_groups": [security_group.id],
},
load_balancers=[{
"target_group_arn": target_group.arn,
"container_name": "plausible",
"container_port": 8000,
}])
load_balancers=[
{
"target_group_arn": target_group.arn,
"container_name": "plausible",
"container_port": 8000,
}
],
)

# Export the load balancer DNS name
pulumi.export("alb_dns", alb.dns_name)
pulumi.export("alb_dns", alb.dns_name) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion pulumi/repo_backups/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
)

# Export the name of the bucket
pulumi.export("bucket_name", bucket.id)
pulumi.export("bucket_name", bucket.id) # type: ignore[attr-defined]
6 changes: 3 additions & 3 deletions pulumi/sentieon_license_server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"DELETE_ME": "",
"Name": "sentieon_test_license_server_vpc",
},
opts=pulumi.ResourceOptions(protect=True),
opts=pulumi.ResourceOptions(protect=True), # type: ignore[attr-defined]
)


Expand Down Expand Up @@ -161,7 +161,7 @@
"Name": "sentieon-license-server-security-group",
},
vpc_id="vpc-09544162c32f4affc",
opts=pulumi.ResourceOptions(protect=True),
opts=pulumi.ResourceOptions(protect=True), # type: ignore[attr-defined]
)


Expand Down Expand Up @@ -208,5 +208,5 @@
subnet_id="subnet-040e9b9afcb44f3f9",
tenancy=aws.ec2.Tenancy.DEFAULT,
vpc_security_group_ids=["sg-0050bb55ca1c6292c"],
opts=pulumi.ResourceOptions(protect=True),
opts=pulumi.ResourceOptions(protect=True), # type: ignore[attr-defined]
)
2 changes: 1 addition & 1 deletion pulumi/test_datasets/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
)

# Export the bucket name
pulumi.export("bucket_name", test_datasets_bucket.bucket)
pulumi.export("bucket_name", test_datasets_bucket.bucket) # type: ignore[attr-defined]

0 comments on commit f505310

Please sign in to comment.