Add aws-native S3 folder example
ADD
aws-native-ts-s3-folder/.gitignore
+/bin/
+/node_modules/

ADD
aws-native-ts-s3-folder/Pulumi.yaml
+name: aws-native-ts-s3-folder
+runtime: nodejs
+description: A static website hosted on AWS S3

ADD
aws-native-ts-s3-folder/index.ts
+// Copyright 2016-2021, Pulumi Corporation.
+
+import * as aws from "@pulumi/aws";
+import * as awsnative from "@pulumi/aws-native";
+import * as pulumi from "@pulumi/pulumi";
+import * as fs from 'fs';
+import * as mime from "mime";
+
+// Create a bucket and expose a website index document
+const siteBucket = new awsnative.s3.Bucket("s3-website-bucket", {
+ websiteConfiguration: {
+ indexDocument: "index.html",
+ },
+});
+
+const siteDir = "www"; // directory for content files
+
+// For each file in the directory, create an S3 object stored in `siteBucket`
+for (const item of fs.readdirSync(siteDir)) {
+ const filePath = require("path").join(siteDir, item);
+ const siteObject = new aws.s3.BucketObject(item, {
+ bucket: siteBucket.id, // reference the s3.Bucket object
+ source: new pulumi.asset.FileAsset(filePath), // use FileAsset to point to a file
+ contentType: mime.getType(filePath) || undefined, // set the MIME type of the file
+ });
+}
+
+// Set the access policy for the bucket so all objects are readable
+const bucketPolicy = new aws.s3.BucketPolicy("bucketPolicy", {
+ bucket: siteBucket.id, // refer to the bucket created earlier
+ policy: siteBucket.arn.apply(bucketArn => JSON.stringify({
+ Version: "2012-10-17",
+ Statement: [{
+ Effect: "Allow",
+ Principal: "*",
+ Action: [
+ "s3:GetObject",
+ ],
+ Resource: [
+ `${bucketArn}/*`, //
+ ],
+ }],
+ })),
+});
+
+// Stack exports
+export const bucketName = siteBucket.bucketName;
+export const websiteUrl = siteBucket.websiteURL;

ADD
aws-native-ts-s3-folder/package.json
+{
+ "name": "aws-native-ts-s3-bucket",
+ "devDependencies": {
+ "@types/node": "^8.0.0"
+ },
+ "dependencies": {
+ "@pulumi/pulumi": "^3.0.0",
+ "@pulumi/aws": "^4.0.0",
+ "@pulumi/aws-native": "^0.1.0",
+ "@types/mime": "^2.0.3",
+ "mime": "^2.5.2"
+ }
+}

ADD
aws-native-ts-s3-folder/tsconfig.json
+{
+ "compilerOptions": {
+ "strict": true,
+ "outDir": "bin",
+ "target": "es2016",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "sourceMap": true,
+ "experimentalDecorators": true,
+ "pretty": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitReturns": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.ts"
+ ]
+}

ADD
aws-native-ts-s3-folder/www/favicon.png
aws-native-ts-s3-folder/www/favicon.png
Binary files /dev/null and b/aws-native-ts-s3-folder/www/favicon.png differ

Add aws-native S3 folder example (#1085)