forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.fs
39 lines (32 loc) · 1.23 KB
/
Program.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module Program
open System.IO
open Pulumi
open Pulumi.FSharp
open Pulumi.Aws.S3.Inputs
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"))))
// For each file in wwwroot ...
let files = Directory.GetFiles "wwwroot"
let bucketObjects =
files
|> Array.map(fun file ->
let name = file.Substring 8
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,
ContentType = input contentType,
Source = input (FileAsset file :> AssetOrArchive)),
CustomResourceOptions (Parent = bucket)))
// Export the name of the bucket
let endpoint = bucket.WebsiteEndpoint.Apply (sprintf "http://%s")
dict [("endpoint", endpoint :> obj)]
[<EntryPoint>]
let main _ =
Deployment.run infra