Hey guys I need some direction or advice. I would ...
# general
b
Hey guys I need some direction or advice. I would like know how I can split my s3 and cloudfront into 2 files. I can't for the life of me figure it out since cloudfront needs the s3 to be referenced. Im using golang btw and both files are in the same stack
m
Can you share a minimal code example? It's impossible to guess what exactly you're trying and which AWS package(s) you're using.
b
I would like to condense this into 2 files and have cloudfront in its own file
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
	}
Copy code
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,
				},
			},
		},
m
Have a look at this tutorial: https://www.pulumi.com/docs/using-pulumi/stack-outputs-and-references/ It doesn't use Go but the pattern is the same. Here's a shorter intro with Go example code: https://www.pulumi.com/learn/building-with-pulumi/stack-references/