/protometa
@lukenimtz
Social media icons made by Dave Gandy from www.flaticon.com are licensed by CC 3.0 BY
Full Stack Javascript (and Devops)
$ curl -sSL https://get.pulumi.com | sh$ pulumi new --dir pulumi-demo-s3-site<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>Hello Javascript Admirers</h1>
</body>
</html>
index.html
-const bucket = new aws.s3.Bucket("my-bucket");
+const bucket = new aws.s3.Bucket("my-bucket", {
+ website: {
+ indexDocument: "index.html"
+ }
+});
index.ts
+new aws.s3.BucketObject("index.html", {
+ bucket: bucket,
+ source: "index.html",
+ contentType: "text/html"
+});index.ts
+export const endpoint = websiteBucket.websiteEndpoint;index.ts
$ pulumi up$ aws s3 ls $(pulumi stack output bucketName)
$ open http://$(pulumi stack output endpoint)// Create an S3 Bucket Policy to allow public read of all objects in bucket
export default function (bucketName: String) {
return JSON.stringify({
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: "*",
Action: [
"s3:GetObject"
],
Resource: [
`arn:aws:s3:::${bucketName}/*` // policy refers to bucket name explicitly
]
}]
})
}
lib/s3-policy.ts
+import s3Policy from "./lib/s3-policy"
...
+new aws.s3.BucketPolicy("bucketPolicy", {
+ bucket: bucket.bucket,
+ policy: bucket.bucket.apply(s3Policy)
+});
index.ts
$ pulumi up$ open http://$(pulumi stack output endpoint)$ pulumi destroy