Have a question for you guys. How are you guys str...
# golang
b
Have a question for you guys. How are you guys structuring you pulumi projects I would love to seperate my s3 file from my cloudfront file as shown. Obviously the cdn has to reference the s3 but my current s3 file is getting a bit long and I would love to know how to split them.
Copy code
func CreateS3Bucket(ctx *pulumi.Context) error {

	// Create an S3 bucket
	bucket, err := s3.NewBucket(ctx, "pulumi-test-bucket", &s3.BucketArgs{
		Website: &s3.BucketWebsiteArgs{
			IndexDocument: pulumi.String("index.html"),
			ErrorDocument: pulumi.String("error.html"),
		},
	})
	if err != nil {
		return err
	}

cdn, err := cloudfront.NewDistribution(ctx, "cdn", &cloudfront.DistributionArgs{
		Enabled: pulumi.Bool(true),
		Origins: cloudfront.DistributionOriginArray{
			&cloudfront.DistributionOriginArgs{
				OriginId:   bucket.Arn,
				DomainName: bucket.BucketRegionalDomainName,
				S3OriginConfig: &cloudfront.DistributionOriginS3OriginConfigArgs{
					OriginAccessIdentity: oai.CloudfrontAccessIdentityPath,
				},
			},
		},
		DefaultCacheBehavior: &cloudfront.DistributionDefaultCacheBehaviorArgs{
			TargetOriginId:       bucket.Arn,
			ViewerProtocolPolicy: pulumi.String("redirect-to-https"),
			AllowedMethods: pulumi.StringArray{
				pulumi.String("GET"),
				pulumi.String("HEAD"),
				pulumi.String("OPTIONS"),
			},
			CachedMethods: pulumi.StringArray{
				pulumi.String("GET"),
				pulumi.String("HEAD"),
				pulumi.String("OPTIONS"),
			},
			DefaultTtl: <http://pulumi.Int|pulumi.Int>(600),
			MaxTtl:     <http://pulumi.Int|pulumi.Int>(600),
			MinTtl:     <http://pulumi.Int|pulumi.Int>(600),
			ForwardedValues: &cloudfront.DistributionDefaultCacheBehaviorForwardedValuesArgs{
				QueryString: pulumi.Bool(false),
				Cookies: &cloudfront.DistributionDefaultCacheBehaviorForwardedValuesCookiesArgs{
					Forward: pulumi.String("none"),
				},
			},
		},
		PriceClass: pulumi.String("PriceClass_200"),

		Restrictions: &cloudfront.DistributionRestrictionsArgs{
			GeoRestriction: &cloudfront.DistributionRestrictionsGeoRestrictionArgs{
				RestrictionType: pulumi.String("none"),
			},
		},
		ViewerCertificate: &cloudfront.DistributionViewerCertificateArgs{
			CloudfrontDefaultCertificate: pulumi.Bool(true),
		},
	})
	if err != nil {
		return err
	}