Reputation: 5010
I use "@google-cloud/compute": "^2.1.0"
to create a VM, and I set 'ONE_TO_ONE_NAT' as shown below.
The issue is that the VM is not created with a public IP.
If I add http:true in the config, then the public IP is created but I would like to avoid the http tag in the config.
For me it looks like a bug as it should work according to the documentation.
Any idea why it is not working? (apart from a bug)
const config = {
//http: true,
machineType: machineType,
disks: [
{
boot: true,
initializeParams: {
sourceImage: SOURCE_IMAGE_PREFIX + projectId + SOURCE_IMAGE_PATH,
},
},
],
networkInterfaces: [
{
network: 'global/networks/default',
accessConfigs: {
type: 'ONE_TO_ONE_NAT',
name: 'External NAT',
},
},
],
metadata: {
items: [
{
key: 'startup-script',
value: `#! /bin/bash
sudo docker run ...
},
],
}
};
Upvotes: 1
Views: 96
Reputation: 75755
It's just a mistake, that took lot of time to find!!!
accessConfigs
is an array!! add [], like this
accessConfigs: [{
type: 'ONE_TO_ONE_NAT',
name: 'External NAT',
}],
Upvotes: 3
Reputation: 35
An empty access_config block would assign an external ephemeral IP to your instance.
network_interface {
network = "default"
access_config {}
}
Upvotes: 0