Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

googleapi: Error 403: The bucket you tried to create is a domain name owned by another user., forbidden #26

Closed
sohailalam2 opened this issue Jun 24, 2018 · 3 comments
Assignees
Labels
area/providers kind/bug Some behavior is incorrect or out of spec
Milestone

Comments

@sohailalam2
Copy link

Use Case:

Create a bucket in GCP to host a static website.

Details:

GCP requires that the bucket should be named as the domain name and that we create a CNAME record in the DNS to point it to google store. I am able to manually create the bucket from GCP Console, with the domain name say, for example, www.myawesomesite.com. However, when I try to create the same programmatically using Pulumi, I end up getting the following error.

NOTE: I am the verified owner of the domain, the domain itself is also verified and I have also already added Pulumi's service account email as the domain owner in Webmaster tools - https://www.google.com/webmasters/tools/dashboard.

Code:

const pulumi = require("@pulumi/pulumi");
const gcp = require('@pulumi/gcp');
const mime = require('mime');
const fs = require('fs');
const path = require('path');

const siteDir = path.join(__dirname, 'www');
const siteBucket = new gcp.storage.Bucket('pulumi-demo-bucket', {
    name: 'www.myawesomesite.com',
    websites: [
        {
            mainPageSuffix: 'index.html',
            notFoundPage: '404.html'
        }
    ]
});
const defaultAcl = new gcp.storage.BucketACL('pulumi-demo-acl', {
    bucket: siteBucket,
    defaultAcl: 'publicRead'
});


// For each file in the directory, create an object stored in `siteBucket`
fs.readdirSync(siteDir)
    .forEach(item => {
        let filePath = path.join(siteDir, item);
        let object = new gcp.storage.BucketObject(item, {
            bucket: siteBucket,
            source: filePath,
            contentType: mime.getType(filePath) || undefined,
        });
    });

// Stack exports
exports.bucketName = siteBucket.name;

ERROR:

$ pulumi update
Previewing update of stack 'plume-demo'
Previewing changes:

 *  pulumi:pulumi:Stack pulumi-demo-plume-demo running
 +  gcp:storage:Bucket pulumi-demo-bucket create
 +  gcp:storage:BucketACL pulumi-demo-acl create
 +  gcp:storage:BucketObject favicon.png create
 +  gcp:storage:BucketObject index.html create

info: 4 changes previewed:
    + 4 resources to create
      1 resource unchanged

Updating stack 'plume-demo'
Performing changes:

 *  pulumi:pulumi:Stack pulumi-demo-plume-demo running
 +  gcp:storage:Bucket pulumi-demo-bucket creating
 +  gcp:storage:Bucket pulumi-demo-bucket creating 1 error. error: Plan apply failed: creating urn:pulumi:plume-demo::pulumi-demo::gcp:storage/bucket:Bucket::pulumi-demo-bucket: googleapi: Error 403: The bucket you tried to create is a domain name owned by another user., forbidden
 +  gcp:storage:Bucket pulumi-demo-bucket **creating failed** 1 error. error: Plan apply failed: creating urn:pulumi:plume-demo::pulumi-demo::gcp:storage/bucket:Bucket::pulumi-demo-bucket: googleapi: Error 403: The bucket you tried to create is a domain name owned by another user., forbidden
 +  gcp:storage:Bucket pulumi-demo-bucket **creating failed** 2 errors. error: update failed
 *  pulumi:pulumi:Stack pulumi-demo-plume-demo done

Diagnostics:
  gcp:storage:Bucket: pulumi-demo-bucket
    error: Plan apply failed: creating urn:pulumi:plume-demo::pulumi-demo::gcp:storage/bucket:Bucket::pulumi-demo-bucket: googleapi: Error 403: The bucket you tried to create is a domain name owned by another user., forbidden

    error: update failed

info: no changes required:
      1 resource unchanged
@ddunkin
Copy link

ddunkin commented Sep 17, 2018

This could possibly be related to #46.

@joeduffy joeduffy added this to the 0.19 milestone Oct 30, 2018
@joeduffy joeduffy added kind/bug Some behavior is incorrect or out of spec area/providers labels Oct 30, 2018
@joeduffy
Copy link
Member

@CyrusNajmabadi This has been around for a while, as part of our GCP work this sprint, can we take a look? @ddunkin Sorry for having missed this one!

@lukehoban
Copy link
Contributor

The immediate issue here appears to be that bucket: siteBucket, should be bucket: siteBucket.id,. If I copy the program above into TypeScript, it catches the two occurrences of this.

Being able to catch this error even in JavaScript is part of https://github.com/pulumi/pulumi-terraform/issues/147. Being able to correctly allow passing siteBucket here is part of effectively pulumi/pulumi-aws#2.

After fixing that (and verifying ownership of a domain), I was able to deploy the above program correctly using latest GCP SDK.

I'll close this one out, but we should look at https://github.com/pulumi/pulumi-terraform/issues/147 in particular in M20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/providers kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

5 participants