Skip to content

Commit

Permalink
Update aws-fs-s3-folder to BucketV2
Browse files Browse the repository at this point in the history
  • Loading branch information
t0yv0 committed Sep 17, 2024
1 parent f143bd3 commit b75a393
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
25 changes: 15 additions & 10 deletions aws-fs-s3-folder/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ open Pulumi.Aws.S3
let infra () =

// Create an AWS resource (S3 Bucket)
let bucket =
Bucket("my-bucket",
BucketArgs (Website = input (BucketWebsiteArgs (IndexDocument = input "index.html"))))
let bucket = BucketV2("my-bucket", BucketV2Args())

let ownershipControls =
let website =
BucketWebsiteConfigurationV2("website",
BucketWebsiteConfigurationV2Args
(Bucket = bucket.Bucket,
IndexDocument = new BucketWebsiteConfigurationV2IndexDocumentArgs(Suffix = "index.html")),
CustomResourceOptions (Parent = bucket))

let ownershipControls =
BucketOwnershipControls("ownership-controls",
BucketOwnershipControlsArgs
(Bucket = io bucket.Id,
Rule = input (BucketOwnershipControlsRuleArgs(ObjectOwnership = input "ObjectWriter"))),
CustomResourceOptions (Parent = bucket))

let publicAccessBlock =
let publicAccessBlock =
BucketPublicAccessBlock("public-access-block",
BucketPublicAccessBlockArgs
(Bucket = io bucket.Id,
Expand All @@ -33,19 +38,19 @@ let infra () =
files
|> Array.map(fun file ->
let name = file.Substring 8
let contentType = if name.EndsWith ".png" then "image/png" else "text/html"
let contentType = if name.EndsWith ".png" then "image/png" else "text/html"

// ... create a bucket object
BucketObject(name,
BucketObjectArgs
(Acl = input "public-read",
Bucket = io bucket.BucketName,
Bucket = io bucket.Bucket,
ContentType = input contentType,
Source = input (FileAsset file :> AssetOrArchive)),
CustomResourceOptions (Parent = bucket, DependsOn = inputList [input ownershipControls; input publicAccessBlock])))

// Export the name of the bucket
let endpoint = bucket.WebsiteEndpoint.Apply (sprintf "http://%s")
let endpoint = website.WebsiteEndpoint.Apply (sprintf "http://%s")
dict [("endpoint", endpoint :> obj)]

[<EntryPoint>]
Expand Down
4 changes: 2 additions & 2 deletions aws-fs-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A static website that uses [S3's website support](https://docs.aws.amazon.com/Am
Previewing update (dev):
Type Name Plan
+ pulumi:pulumi:Stack aws-cs-s3-folder-dev create
+ └─ aws:s3:Bucket my-bucket create
+ └─ aws:s3:BucketV2 my-bucket create
+ ├─ aws:s3:BucketObject index.html create
+ └─ aws:s3:BucketObject favicon.png create
Expand All @@ -36,7 +36,7 @@ A static website that uses [S3's website support](https://docs.aws.amazon.com/Am
Updating (dev):
Type Name Status
+ pulumi:pulumi:Stack aws-cs-s3-folder-dev created
+ └─ aws:s3:Bucket my-bucket created
+ └─ aws:s3:BucketV2 my-bucket created
+ ├─ aws:s3:BucketObject index.html created
+ └─ aws:s3:BucketObject favicon.png created
Expand Down
2 changes: 1 addition & 1 deletion aws-fs-s3-folder/aws-cs-s3-folder.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Pulumi" Version="3.*" />
<PackageReference Include="Pulumi.FSharp" Version="3.*" />
<PackageReference Include="Pulumi.Aws" Version="5.*" />
<PackageReference Include="Pulumi.Aws" Version="6.*" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit b75a393

Please sign in to comment.