I'm trying to deploy a cloud function via my local terminal. For this i use the following code:
gcloud beta functions deploy networkcheck \
--region=europe-west1 \
--project=project-id \
--entry-point functionName \
--trigger-event providers/cloud.firestore/eventTypes/document.write \
--trigger-resource projects/project-id/databases/(default)/documents/test/test_id \
--runtime nodejs8
This will result in the following error:
deploy.sh: line 7: syntax error near unexpected token `('
deploy.sh: line 7: ` --trigger-resource projects/project-id/databases/(default)/documents/test/test_id \'
The script executes perfectly fine when i change '(default)' to 'default or any other string'. But then the cloud function will not work, because the only id that can be used for an Firestore database is '(default)', as mentioned in this post: How to find the database id of a cloud firestore project?
Is this a bug? Or can i fix this somehow?
Parenthesis are special characters in the bash command shell. You will need to escape them so they are taken literally, instead of being interpreted by your shell. Here, I am just putting the --trigger-resource parameter in single quotes so the parenthesis won't have a special meaning:
--trigger-resource "projects/project-id/databases/(default)/documents/test/test_id"
Related
I am trying to download the exported data from my GSuite (Google Workplace) account. I want to download multiple selected files.
I tried running the following command:
gsutil -m cp \
"gs://dummy-top-3bb5g8a2-s940-412a-bece-6f830889cc83/Status\ Red.pdf" \
"gs://dummy-top-export-3bb5g8a2-s940-412a-bece-6f830889cc83/Status\ Report.jpg" \
.
...but it failed with an error:
CommandException: Wrong number of arguments for "cp" command.
How do I download my files?
Somehow, the backslashes are not successfully escaping the newline characters (maybe there's some other whitespace characters after the trailing backslashes?), thus the arguments on the subsequent lines are not being passed to the command.
I am using this CloudFormation template
The List parameter I'm trying to pass values to is:
"Subnets" : {
"Type" : "List<AWS::EC2::Subnet::Id>",
"Description" : "The list of SubnetIds in your Virtual Private Cloud (VPC)",
"ConstraintDescription" : "must be a list of at least two existing subnets associated with at least two different availability zones. They should be residing in the selected Virtual Private Cloud."
},
I've written an utility script that looks like this:
#!/bin/bash
SUBNET1=subnet-abcdef
SUBNET2=subnet-ghijlm
echo -e "\n==Deploying stack.cf.yaml===\n"
aws cloudformation deploy \
--region $REGION \
--profile $CLI_PROFILE \
--stack-name $STACK_NAME \
--template-file stack.cf.json \
--no-fail-on-empty-changeset \
--capabilities CAPABILITY_NAMED_IAM \
--parameter-overrides \
VpcId=$VPC_ID \
Subnets="$SUBNET1 $SUBNET2" \ #<---------------this fails
InstanceType=$EC2_INSTANCE_TYPE \
OperatorEMail=$OPERATOR_EMAIL \
KeyName=$KEY_NAME \
If I deploy this, after a while my stack fails to deploy saying that a Subnet with the value "subnet-abcdef subnet-ghijlmn" does not exist.
The correct way to pass parameters to list is to comma separate them
So:
#!/bin/bash
SUBNET1=subnet-abcdef
SUBNET2=subnet-ghijlm
aws cloudformation deploy --parameter-overrides Subnets="$SUBNET1,SUBNET2"
will work
Tried every possible solution found online, none worked.
According to the documentation below, you should escape the comma without double-slashes. Tried that, didn't work either.
https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html
What worked FOR ME (apparently this is very environment-dependent) was the command below, escaping the coma with just one slash.
aws cloudformation create-stack --stack-name teste-memdb --template-body file://memorydb.yml --parameters ParameterKey=VpcId,ParameterValue=vpc-xxxx ParameterKey=SubnetIDs,ParameterValue=subnet-xxxxx\,subnet-yyyy --profile whatever
From the Documentation here
List/Array can be passed just like python Lists.
'["value1", "value2", "value3"]'
Also to note Cloudformation internally used python.
I'm trying to run the az sql db export command and it requires a SQL Admin username and password. Our password happens to have two dollar signs in it e.g. ABC$$123==). So when I run the following command (with valid values in it, of course):
$pwd = "ABC$$123==)"
az sql db export -s myserver -n mydatabase -g mygroup -p $pwd-u login \
--storage-key MYKEY== --storage-key-type StorageAccessKey \
--storage-uri https://myAccountName.blob.core.windows.net/myContainer/myBacpac.bacpac
I get this response:
')' is not recognized as an internal or external command,
operable program or batch file.
I've tried so many variations of escaping this but haven't found the correct method that works. In the end, I plan to read the password from Azure Key Vault and was gonna pass it straight in to the az cli command. What do I have to do to get this to work?
There are two types of quotes in powershell - single and double. In the double quote, you can pass in variables. In a single quote, everything is literal. For cases like your password, I would recommend just using the literal:
$pwd = 'ABC$$123==)'
I'm executing gcloud composer commands:
gcloud composer environments run airflow-composer \
--location europe-west1 --user-output-enabled=true \
backfill -- -s 20171201 -e 20171208 dags.my_dag_name \
kubeconfig entry generated for europe-west1-airflow-compos-007-gke.
It's a regular airflow backfill. The command above is printing the results at the end of the whole backfill range, is there any way to get the output in a streaming manner ? Each time a DAG gets backfilled it will be printed in the standard output, like in a regular airflow-cli.
I am trying to query the output of an AWS cli command using an environment variable as the query string. This works fine for me using the AWS Cli in Linux but in Powershell I am having trouble getting the Cli to use the variable in Powershell.
For example - thsi works for me in Linux:
SECGRP="RDP from Home"
aws ec2 describe-security-groups --query \
'SecurityGroups[?GroupName==`'"$SECGRP"'`].GroupId' --output text
If i run this in Powershell:
$SECGRP="RDP from Home"
aws ec2 describe-security-groups --query \
'SecurityGroups[?GroupName==`'"$SECGRP"'`].GroupId' --output text
Error Details:
Bad value for --query SecurityGroups[?GroupName==`: Bad jmespath
expression: Unclosed ` delimiter:
SecurityGroups[?GroupName==`
^
I have tried a few combinations of quotes inisde the query expression but either get errors or no output.
I have also run the following to demonstrate i can get the correct output using Powershell (but not using a variable):
aws ec2 describe-security-groups --query \
'SecurityGroups[?GroupName==`RDP from Home`].GroupId' --output text
Try this:
$SECGRP="RDP from Home"
aws ec2 describe-security-groups --query "SecurityGroups[?GroupName=='$SECGRP'].GroupId" --output text