sparse-intern-71089
11/18/2023, 6:04 PMmagnificent-soccer-44287
11/18/2023, 6:07 PMmagnificent-soccer-44287
11/18/2023, 6:07 PMpanic: interface conversion: interface {} is nil, not map[string]interface {}magnificent-soccer-44287
11/18/2023, 6:18 PMconst distribution = new aws.cloudfront.Distribution(pre('redirectCdn'), {
    origins: prodRedirectBucket.websiteEndpoint.apply(endpoint => {
		console.dir(`ENDPOINT ${endpoint}`)
		return [{
			domainName: endpoint,
			originId: prodRedirectBucket.arn,
		}]incalculable-motherboard-92742
11/21/2023, 7:23 PMadorable-receptionist-25731
01/23/2024, 10:18 PMmagnificent-soccer-44287
01/24/2024, 12:15 AMpulumi.interpolate(`var`);pulumi.interpolate`var`;adorable-receptionist-25731
01/24/2024, 9:57 AMmagnificent-soccer-44287
01/24/2024, 4:27 PMadorable-receptionist-25731
01/25/2024, 8:33 AMmagnificent-soccer-44287
01/25/2024, 2:04 PMincalculable-motherboard-92742
01/25/2024, 4:33 PMimport * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";
// Create an S3 bucket and enable it as a website
const siteBucket = new aws.s3.Bucket("siteBucket", {
    website: {
        indexDocument: "index.html",
    },
});
// Create a CloudFront origin access identity to give CloudFront access to the S3 bucket
const originAccessId = new aws.cloudfront.OriginAccessIdentity("originAccessId");
// Create a CloudFront distribution with the S3 bucket as an origin
const cdn = new aws.cloudfront.Distribution("cdn", {
    origins: [{
        domainName: siteBucket.bucketRegionalDomainName,
        originId: siteBucket.arn,
        s3OriginConfig: {
            originAccessIdentity: originAccessId.cloudfrontAccessIdentityPath,
        },
    }],
    enabled: true,
    defaultCacheBehavior: {
        targetOriginId: siteBucket.arn,
        viewerProtocolPolicy: "redirect-to-https",
        allowedMethods: ["GET", "HEAD", "OPTIONS"],
        cachedMethods: ["GET", "HEAD"],
        defaultTtl: 3600,
        maxTtl: 86400,
        minTtl: 0,
        forwardedValues: {
            queryString: false,
            cookies: { forward: "none" },
        },
    },
    restrictions: {
        geoRestriction: {
            restrictionType: "none",
        },
    },
    viewerCertificate: {
        cloudfrontDefaultCertificate: true,
    },
});
// Export the name of the bucket and the CDN URL
export const bucketName = siteBucket.id;
export const cdnURL = cdn.domainName;
// Export a variable with the interpolated string
export const interpol = pulumi.interpolate`The bucket name is ${siteBucket.id} and the CDN URL is ${cdn.domainName}`;incalculable-motherboard-92742
01/25/2024, 4:36 PM❯ AWS_PROFILE=work pulumi up --yes
Previewing update (dev)
View in Browser (Ctrl+O): <https://app.pulumi.com/diana-pulumi-corp/interpol/dev/previews/0781b8a1-f08d-47c7-977c-696b69415444>
     Type                            Name          Plan       
     pulumi:pulumi:Stack             interpol-dev             
 +   └─ aws:cloudfront:Distribution  cdn           create     
Outputs:
  + bucketName: "sitebucket-7783c10"
  + cdnURL    : output<string>
  + interpol  : output<string>
Resources:
    + 1 to create
    3 unchanged
Updating (dev)
View in Browser (Ctrl+O): <https://app.pulumi.com/diana-pulumi-corp/interpol/dev/updates/2>
     Type                            Name          Status             
     pulumi:pulumi:Stack             interpol-dev                     
 +   └─ aws:cloudfront:Distribution  cdn           created (537s)     
Outputs:
  + bucketName: "sitebucket-7783c10"
  + cdnURL    : "<http://d2i8q82xz58e4h.cloudfront.net|d2i8q82xz58e4h.cloudfront.net>"
  + interpol  : "The bucket name is sitebucket-7783c10 and the CDN URL is <http://d2i8q82xz58e4h.cloudfront.net|d2i8q82xz58e4h.cloudfront.net>"
Resources:
    + 1 created
    3 unchanged
Duration: 9m3sadorable-receptionist-25731
01/29/2024, 8:04 AMconst policyCondition = callerIdentity.accountId.apply(accountId => {
    return bucket.id.apply(bucketId => {
      return {
        sourceArn: `arn:aws:cloudfront::${accountId}:distribution/${bucketId}`,
      };
    });
  });magnificent-soccer-44287
01/29/2024, 8:06 AMmagnificent-soccer-44287
01/29/2024, 8:06 AMpulumi.all([callerIdentity.accountId,bucket.id]).apply(([accountId, bucketId]) => {
    return {
        sourceArn: `arn:aws:cloudfront::${accountId}:distribution/${bucketId}`,
      };
})magnificent-soccer-44287
01/29/2024, 8:06 AMmagnificent-soccer-44287
01/29/2024, 8:09 AMadorable-receptionist-25731
01/29/2024, 8:15 AM