0
votes

I am using GCP deployment manager to deploy a gcp cloud storage bucket. My YAML file is uploaded in another existing gcp cloud storage bucket and I run following commands on gcp cloud shell in order to create deployment. I specify the link url in the commands to create deployment ( see below)

$gcloud config set project my-project-name
$gcloud deployment-manager deployments create bkt-deployer  --config https://storage.cloud.google.com/mybucket/UCABkt-V4.yaml

And I get following error

 Failed to parse YAML: mapping values are not allowed here
  in "<unicode string>", line 11, column 14:
      font-family: 'Open Sans';
                 ^ (line: 11)

I figured that I get the YAML parse error despite specifying a wrong bucket name so I suspect that it is owing to issue with inaccessibility of YAML. I tried fixing permissions on bucket and individual YAML but no avail . I still get this error which in my opinion is really misleading.

While the actual YAML format isnt relevant , still jsut FYI my YAML file looks as follows (see code block)

resources:
- name: deployment-manager-bucket-2
  type: storage.v1.bucket
  properties:
    predefinedAcl: projectPrivate
    projection: full
    location: US
    storageClass: STANDARD
    lifecycle:
      rule:
      - action: 
        type: SetStorageClass storage_class = "NEARLINE" 
        condition:
          age: 30
      - action:
        type: SetStorageClass storage_class = "COLDLINE"
        condition:
          age: 90

so a couple questions

1) What is best way to provide YAML configuration to deployment manager? Is uploading yaml config file to a gcp object storage bucket and then specifying its link URL the way I did, an optimal option? or is there an alternative way for providing path of YAML to gcp cloud shell for deployment creation?

2) And assuming that eventually I get past that hurdle of specifying the deployment the path my YAML and ensuring there are no access and permission issues, does my YAML syntax look ok? Especially the lifecyle rule specification that assign Nearline and coldline storage classes on aging 30 and 90 days respectively

A huge thanks for your help.

Best regards

Yogesh

2
Which editor did you use to create the YAML? The error messages look like you used a document editor, which formats text for display. - John Hanley

2 Answers

1
votes

The beginning of your YAML file seams corrupted:

resources:
- name: deployment-manager-bucket-2
type: storage.v1.bucket
properties:

Space are missing before type and properties.

Then, the issue that you have on your deployment, is because your yaml file isn't accessible. You got a "font family" issue which is in the CSS of the access error page. Try it yourself! curl -L https://storage.cloud.google.com/mybucket/UCABkt-V4.yaml

You should got

<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
  <meta content="width=300, initial-scale=1" name="viewport">
  <meta name="google-site-verification" content="LrdTUW9psUAMbh4Ia074-BPEVmcpBxF6Gwf0MSgQXZs">
  <title>Sign in - Google Accounts</title>
  <style>
  @font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 300;
...

So you have to make your file or your bucket publicly accessible. Not very safe and professional.

I propose a solution: use Cloud Build.

  1. use gsutil builder to get your files into Cloud Build environment
  2. use gcloud builber to run deployment manager

Cloud Build has the permission for accessing to the bucket of your project.

0
votes

I found the precise reason why it is failing thanks to comment by @guillaume When I do a "wget" from cloud shell to the "link" URL that I get from the cloud storage then I dont get the YAML itself but I get back a redirect link that I suppose browsers follow but deployment manager command line does not. It tries to interpret the server response as a YAML and throws error. See the wget response below
So now I know the reason - and I guess I conclude that using a gcp storage bucket to store yaml for deployment manager is a bad idea.

SIMPLE SOLUTION. - Edit your yaml files in place in the gcp command line tool or directly upload them to your shell and use them locally.

And for everyone's benefit I edited my YAML in the question. Whats up there now is perfectly valid now :-)

wget https://storage.cloud.google.com/mybucket/myyaml.yaml
--2019-09-24 12:15:23--  
https://storage.cloud.google.com/mybucket/myyaml
Resolving storage.cloud.google.com 
(storage.cloud.google.com)...    
Connecting to storage.cloud.google.com 
(storage.cloud.google.com)| :443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://accounts.google.com/ServiceLogin? service=cds&passive=1209600&continue=https://storage.cloud.google .com/mybucket/myyaml.yaml&followup=https://storage.cloud.google.com/dmybucket/myyaml.yaml [following]
--2019-09-24 12:15:23--  
https://accounts.google.com/ServiceLogin?service=cds&passive=1209600&continue=https://storage.cloud.google.com/mybucket/myyaml.yaml&followup=https://storage.cloud.google.com/dmybucket/myyaml.yaml
Resolving accounts.google.com (accounts.google.com)...
Connecting to accounts.google.com 
(accounts.google.com) ... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘myyaml.yaml’

myyaml.yaml [ <=>                            ]  xx.xxK  --.-KB/s    in 0.0xxs