Adding multiple tags when creating a VM - tags

Using the code below to create VM with two tags, only the last one remains. Documentations says to use --tags=TAG,[TAG,…] but that does not work. Any help would be great. Thanks. I have tried the following, with several variations, but it does not work:
gcloud compute instances create vm-1 \
--image-project windows-cloud \
--image-family windows-2016 \
--tags allowhttp \
--tags allowprivaterdp \
--machine-type n1-standard-1 \
--boot-disk-size 77GB \
--boot-disk-type pd-ssd \
--network-interface '' \
--network-interface subnet=ssubnet,private-network-ip=192.168.64.22
Tried to add multiple parms with and without commas, brackets, quotes and GCP does not like it. I don't want to add the tags as a separate step, gcloud compute instances add-tags vm-b --zone us-east1-b --tags mytags, since it appears this could be easily added at creation just don't have the right syntax it appears. Documentations says to use --tags=TAG,[TAG,…] but that does not work.
Expected to see two tags added to the VM, only the last one remains and other syntax changes dont allow the VM to be created

Although the question is old, I would answer it as it is unanswered,
the correct syntax to add multiple tags to a VM instance while its creation is as follows:
gcloud compute instances create www1 \
--image-family debian-9
--image-project debian-cloud
--zone us-central1-a
--machine-type=n1-standard-1
--subnet=default
--tags network-lb-tag1,network-lb-tag2,network-lb-tag3
This assigns 3 tags to the instance upon its creation.
The documentation correctly specifies it as --tags=TAG,[TAG,…], which means if there are multiple tags to be added, its value should be added in continuation to the 1st value separated by a comma.
-Ak

Related

Execute AWS ECS run-task with network configuration overrides

I'm running a task in AWS ECS using the CLI command run-task.
I'm successfully running a task as follows:
aws ecs run-task --cluster ${stackName}-cluster \
--task-definition ${stackName}-${tag} \
--launch-type="FARGATE" \
--network-configuration '{ "awsvpcConfiguration": { "assignPublicIp":"DISABLED", "securityGroups": ["sg-......"], "subnets": ["subnet-.....","subnet-.....","subnet-......"]}}' \
--count 1 \
--profile ${profile} \
--overrides file://overrides.json
They way I understand it, if you're using FARGATE you must to have NetworkMode: awsvpc in your TaskDefinition, and you need to specify the awsvpcConfiguration every time you run a task. This is all fine.
However, to make the above invocation tidier, is there a way to pass the --networkConfiguration above as an override. The documentation says you can pass environment variables, but it's not clear if this includes network.
I would be very grateful to anybody who could shed some light on this.
No you can't do that. Here's the full list of things you can specify in ECS Task Overrides. Network configuration is not in that list.
The documentation says you can pass environment variables, but it's not clear if this includes network.
The network configuration is not an environment variable.
If you just want to be able to simplify the the command line by passing in more arguments from a file, you can use the --cli-input-json
or --cli-input-yaml arguments.

Getting a list of all VMs from all Projects in GCP

I am new to GCP, and trying to get a list of all the VMs excluding GKEs from all the projects in a GCP organization. I wanted to check if anyone was able to do it using a script or a command, perhaps. Any help would be greatly appreciated.
I can get the list of VMs for a single project but not from all the projects recursively. There are quite a few projects to get the list of VMs manually.
Apologies. I was able to run the query to filter out only VM instances and exclude GKE instances from all projects using the following query
gcloud asset search-all-resources \
--scope='organizations/<Organization ID>' \
--query='NOT labels:goog-gke-node' \
--asset-types='compute.googleapis.com/Instance' \
--order-by='createTime'

gcloud list instances in managed group sorted by creation time

I need to get the oldest instance from an instance group. I am using the following command:
gcloud compute instance-groups managed list-instances "instance-group-name" --region "us-central1" --format="value(NAME,ZONE,CREATION_TIMESTAMP)" --sort-by='~CREATION_TIMESTAMP'
But it seems --sort-by is not working or I am using it a bit wrong.
Could you please suggest the right way.
It's probably creationTimestamp not CREATION_TIMESTAMP.
See: instances.list and the response body for the underlying field names.
It's slightly confusing but gcloud requires you to use the (field|property) names of the underlying request|response types not the output names.
Another way to more readily determine this is to add --format=yaml or --format=json to gcloud compute instances list (or any gcloud command) to get an idea of what's being returned so that you can begin filtering and formatting it.

GCloud Function not firing after Firestore Create

I've deployed a function to gcloud using the following command line script:
gcloud functions deploy my_new_function --runtime python37 \
--trigger-event providers/cloud.firestore/eventTypes/document.create \
--trigger-resource projects/my_project_name/databases/default/documents/experiences/{eventId}
This worked successfully, and my function was deployed. Here is what I expected to happen as a result:
Any time a new document was created within the experiences firestore collection, the function my_new_function would be invoked.
What is actually happening:
my_new_function is never being invoked as a result of a new document being created within experiences
The --source parameter is for deploying from source control, which you are not trying to do . You will want to deploy from your local machine instead. You run gcloud from the directory you want to deploy.

Alternate ways of obtaining gcloud alpha compute rolling-updates list

When executing gcloud rolling update list the following error is thrown :
gcloud alpha compute rolling-updates list --group some-group --zone us-east1-b
ERROR: (gcloud.alpha.compute.rolling-updates.list) Collection [replicapoolupdater.rollingUpdates] is not registered
Is there a way around this issue using gcloud ?
This alpha list command was broken sometime in March. The fix for it will be coming out most likely this Wednesday with release 115.0.0.
You can also grab very old gcloud (probably a version before 99.0.0) from https://storage.cloud.google.com/cloud-sdk-release.
Note that this command group will be deprecated as soon as replacement is place, and users are discouraged from using it.