Hello, I have been utterly puzzled on how to creat...
# getting-started
t
Hello, I have been utterly puzzled on how to create an api config on gcp. The required properties are content and path, content is fairly self explanatory but any path I try to give it spits back a 404 at me?
Copy code
gcp:apigateway:ApiConfig (discord-webhook-config):
    error: 1 error occurred:
        * Error creating ApiConfig: googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
  <html lang=en>
    <meta charset=utf-8>
    <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
    <title>Error 404 (Not Found)!!1</title>
  
...
https://www.pulumi.com/docs/reference/pkg/gcp/apigateway/apiconfig/#apiconfigopenapidocumentdocument Any help would be greatly appreciated!
w
Can you share your code?
t
Sure!
Copy code
import * as path from 'path';
import { promises as fs} from 'fs';
import { apigateway } from '@pulumi/gcp';

const specificationRequest = fs.readFile(path.join(__dirname, 'src', 'stack', 'specification.yaml'))
	.then(content => content.toString('base64'))

const api = new apigateway.Api('sweet-autumn-api', {
	displayName: 'Sweet Autumn API',
	apiId: 'sweet-autumn-api',
});

const apiConfig = new apigateway.ApiConfig('discord-webhook-config', {
	displayName: 'Discord Webhook API Config',
	api: api.id,
	openapiDocuments: [{
		document: {
			contents: specificationRequest,
			path: 'test.yaml'
		}
	}]
});

const gateway = new apigateway.Gateway('discord-webhook-gateway', {
	displayName: 'Discord Webhook Gateway',
	gatewayId: 'discord-webhook-gateway',
	apiConfig: apiConfig.id,
	region: 'europe-west1'
});

export const apiId = api.id;
export const apiConfigId = apiConfig.id;
export const gatewayId = gateway.id;
w
Can you share your
specification.yaml
file?
And, can you share the entire error message? After the “Error 404 (Not Found)” bit is there additional error information?
t
Here's specification.yaml, side node: It does work when creating the api config from the console, just not from pulumi
And here's the full error:
Copy code
error: 1 error occurred:
        * Error creating ApiConfig: googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
    <html lang=en>
      <meta charset=utf-8>
      <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
      <title>Error 404 (Not Found)!!1</title>
      <style>
        *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-re
peat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/go
oglelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.g
<http://oogle.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png|oogle.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png>) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 1
00%}}#logo{display:inline-block;height:54px;width:150px}
      </style>
      <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
      <p><b>404.</b> <ins>That's an error.</ins>
      <p>The requested URL <code>/v1beta/projects/sweet-autumn/locations/global/apis/projects/sweet-autumn/locations/global/apis/sweet-autumn-api/configs?alt=json&apiConfigId=terraform-20210312141801092200000001</code> was not found on this server.  <ins>That's all w
e know.</ins>
w
@thousands-arm-78308 I think the issue is that in your ApiConfig declaration you want to use
api: api.apiId
and not
api: api.id
The
id
property is the whole “path” for the Api, but the ApiConfig only wants the “name” of the API which is actually
apiId
If you export your entire
api
you’ll see the properties and it’ll make a bit more sense what I’m saying.
t
That was probably the issue, Thank you so much! Fixing this problem however has revealed another error which I am equally as clueless on how to approach:
Copy code
error: 1 error occurred:
        * Error creating ApiConfig: googleapi: Error 400: Service account "projects/-/serviceAccounts/29777571002-compute@developer.gserviceaccount.com" not found. Try specifying a service account that exists in this project.
In the console when creating an api config it requires you to specify a service account but I find so much options in the args for the ApiConfig in pulumi, perhaps related?
w
Fwiw, when I was testing this I didn’t specify a service account and it worked. If you want to specify a service account you can create one in Pulumi with the Serviceaccount resource
t
I see, that is good to know. Thank you for all your help!