backends should never create unmanaged resources

The backend was creating bucket named in the configuration if it didn't
exist. We don't allow other backends to do this, because these are not
managed resources that terraform can control.
This commit is contained in:
James Bardin 2017-12-06 16:47:29 -05:00
parent f461c1750c
commit aec45e6967
1 changed files with 1 additions and 18 deletions

View File

@ -128,22 +128,5 @@ func (b *gcsBackend) configure(ctx context.Context) error {
b.storageClient = client
return b.ensureBucketExists()
}
func (b *gcsBackend) ensureBucketExists() error {
_, err := b.storageClient.Bucket(b.bucketName).Attrs(b.storageContext)
if err != storage.ErrBucketNotExist {
return err
}
if b.projectID == "" {
return fmt.Errorf("bucket %q does not exist; specify the \"project\" option or create the bucket manually using `gsutil mb gs://%s`", b.bucketName, b.bucketName)
}
attrs := &storage.BucketAttrs{
Location: b.region,
}
return b.storageClient.Bucket(b.bucketName).Create(b.storageContext, b.projectID, attrs)
return nil
}