Skip to content

Commit

Permalink
refactor: rename bucket variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcello Romani committed Nov 2, 2023
1 parent f2f65aa commit cf98d43
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions infra/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ def build_public_read_policy_for_bucket(bucket_name):
pulumi.export('zone_id', lmgify_net_zone.id)

# Create s3 bucket to serve static content from
site_s3_bucket = aws.s3.Bucket(
content_bucket = aws.s3.Bucket(
"lmgify.net",
bucket=target_domain,
website=aws.s3.BucketWebsiteArgs(
index_document="index.html",
)
)
pulumi.export('site_s3_bucket', site_s3_bucket.id)
pulumi.export('site_s3_bucket_url', site_s3_bucket.website_endpoint)
pulumi.export('site_s3_bucket', content_bucket.id)
pulumi.export('site_s3_bucket_url', content_bucket.website_endpoint)

# The bucket must be public
public_access_block = aws.s3.BucketPublicAccessBlock(
'allow-public-access-to-website',
bucket=site_s3_bucket.id,
bucket=content_bucket.id,
block_public_acls=False,
)

site_s3_bucket_policy = aws.s3.BucketPolicy(
'allow-public-access-to-website',
bucket=site_s3_bucket.id,
policy=build_public_read_policy_for_bucket(site_s3_bucket.id),
bucket=content_bucket.id,
policy=build_public_read_policy_for_bucket(content_bucket.id),
opts=ResourceOptions(
depends_on=[
public_access_block,
Expand All @@ -69,7 +69,7 @@ def build_public_read_policy_for_bucket(bucket_name):
mime_type, _ = mimetypes.guess_type(file_path)
index_obj = aws.s3.BucketObject(
"index.html",
bucket=site_s3_bucket.id,
bucket=content_bucket.id,
source=FileAsset(file_path),
content_type=mime_type,
)
Expand All @@ -82,8 +82,8 @@ def build_public_read_policy_for_bucket(bucket_name):
type="A",
aliases=[
aws.route53.RecordAliasArgs(
name=site_s3_bucket.website_endpoint,
zone_id=site_s3_bucket.hosted_zone_id,
name=content_bucket.website_endpoint,
zone_id=content_bucket.hosted_zone_id,
evaluate_target_health=False,
)
],
Expand Down

0 comments on commit cf98d43

Please sign in to comment.