Error parsing parameter '--targets': Expected: '=', received: '{' for input: - amazon-web-services

I am creating a crawler through AWS CLI in Glue, but facing issue.
Here's the CLI Command that i use
aws glue create-crawler \
--name "mytestcrawlernew" \
--role "arn:aws:iam::role/AWSGlueServiceRole-AWSGlueServiceRole" \
--database-name "mydb" \
--description "This is the test Crawler" \
--targets "JdbcTargets":{"ConnectionName":"RS_Connection"}
Am i doing anything wring, cause i am facing the subjected issue

On the official documentation here, you can have a look at the proper syntax like in this example:
aws glue create-crawler
--name comprehend-analysis-crawler
--role glue-iam-role-arn
--targets S3Targets=[
{Path="s3://DOC-EXAMPLE-BUCKET/sentiment-results"},
{Path="s3://DOC-EXAMPLE-BUCKET/entities-results"}]
--database-name comprehend-results
Look carefully that you are stating --targets "JdbcTargets" and it looks like it should be --targets JdbcTargets=[

Related

Retrieve Google Dataflow user defined labels in Google Monitoring & Logging

I'm running a Dataflow job using the gcloud command with the --parameters labels='{"my_label":"my_value"}' parameter in order to set custom labels (which I can see in the Job Info panel in the UI).
But unfortunately, I'm not able to retrieve this custom label in the Logging stack: I can see the classic Dataflow labels (dataflow.googleapis.com/job_name, dataflow.googleapis.com/job_id, etc.) and the Resource ones (step_id, project_id, region, etc.) but not my my_label custom label.
Is there something I'm missing or is that label propagation I'm expecting does not exist?
Thanks!
EDIT Here is the full command I'm using to run my Dataflow job:
gcloud dataflow flex-template run "my-dataflow-job" \
--template-file-gcs-location "gs://$(GCP_BUCKET)/my-dataflow-job/templates/my-dataflow-job.json" \
--region "$(GCP_REGION)" \
--parameters tempLocation="gs://$(GCP_BUCKET)/my-dataflow-job/temp" \
--parameters stagingLocation="gs://$(GCP_BUCKET)/my-dataflow-job/staging" \
--parameters usePublicIps=false \
--project "$(GCP_PROJECT)" \
--worker-machine-type="$(DATAFLOW_WORKER_MACHINE_TYPE)" \
--num-workers=1 \
--max-workers=1 \
--parameters labels='{"my_label":"my_value"}'

AWS CLI restore-from-cluster-snapshot doesn't find snapshot in account

I'm trying to restore a cluster from a snapshot using
aws redshift restore-from-cluster-snapshot --cluster-identifier my-cluster
--snapshot-identifier my-identifier --profile my-profile --region my-region
But I'm receiving
An error occurred (ClusterSnapshotNotFound) when calling
the RestoreFromClusterSnapshot operation: Snapshot not found: my-identifier
I checked the available snapshots using
aws redshift describe-cluster-snapshots --profile my-profile --region my-region
And my-identifier appears as available snapshot.
Entering via Redshift console I'm also able to see the snapshots and was able to restore it from the UI.
Does anybody have any clues ?
P.S.: Not sure if it's relevant, but it's a snapshot from another account that I shared with the account where I'm trying to restore the cluster
You must specify the owner account number when restoring to enable Redshift to decrypt the shared snapshot.
aws redshift restore-from-cluster-snapshot \
--profile myAwsCliProfile \
--snapshot-identifier mySnapshotName \
--owner-account 012345678910 \
--cluster-identifier my-new-redshift-cluster \
--number-of-nodes 6 \
--node-type ra3.16xlarge \
--port 5439 \
--region us-east-1 \
--availability-zone us-east-1d \
--cluster-subnet-group-name default\
--availability-zone-relocation \
--no-publicly-accessible \
--maintenance-track-name CURRENT

AWS CLI create ECR repo

I am trying to create a ECR repo with list of tags from the AWS cli. This is the command I am running. I need to pass in the tags as JSON
aws ecr create-repository \
--repository-name alpha/sample-repo \
--region us-west-2 \
--tags [{"Key":"env","Value":"dev"},{"Key":"team","Value":"finance"}]
and getting the below error
Error parsing parameter '--tags': Invalid JSON:
[Key:env]
what am i missing here? How to make it work?
Try enclosing the tags with a single quote
aws ecr create-repository \
--repository-name alpha/sample-repo \
--region us-west-2 \
--tags '[{"Key":"env","Value":"dev"},{"Key":"team","Value":"finance"}]'

Cannot seem to get format of AWS Rekognition right in AWS CLI

Tried running AWS Rekognition in AWS CLI and got the following error
Error parsing parameter '--image': Invalid JSON: Expecting value: line 1 column 48 (char 47)
Also tried adjusting the " and ' but got the same error message. Appreciate all the help!
Code as follows:
aws rekognition index-faces --image "{\"S3Object\":{\"Bucket\":\"xxx\",\"Name\":"image.PNG"}}" --collection-id "\xxx"\ --detection-attributes \"ALL\" --external-image-id \"xxx\" --region us-west-2
Thanks in advance!
Here is a command I have successfully used:
aws rekognition index-faces \
--collection-id Trainers \
--image "S3Object={Bucket=my-bucket,Name=John.jpg}" \
--detection-attributes ALL \
--external-image-id John

Access updated lambda version from command: `aws lambda publish-version`

My CI pipeline will do two things
generate new lambda version and publish
Update an alias to point at that new version
This will be done via cli commands. My question is, how do I access the version number that been generated from the first command. It is returned and posted to the CLI. Can this be access easily via some nifty was command or will I have to parse it myself?
e.g.
version=$(aws lambda publish-version \
--function-name test_lambda --description "updated via cli" --region eu-west-1 \
--query Version \
--output text)
See Controlling Command Output from the AWS Command Line Interface page of AWS CLI User Guide, specifically How to Filter the Output with the --query Option and Text Output Format
This works but still curious if there is a better way.
version=$(aws lambda publish-version --function-name test_lambda --description "updated via cli" --region eu-west-1| jq '.Version')
NEW_LAMBDA_VERSION=$(aws lambda list-versions-by-function --function-name $LAMBDA_NAME_FOR_DEPLOY --no-paginate --query "max_by(Versions, &to_number(to_number(Version) || '0'))")
NEW_LAMBDA_VERSION=$(echo $NEW_LAMBDA_VERSION | jq -r .Version)
echo $NEW_LAMBDA_VERSION
In this case, I use on .gitlab-ci.yml.