Skip to main content

Posts

Showing posts from May, 2018

Changing AWS API GATEWAY Resource Name - Using the CLI

One of these days i had to rename a resource name on the AWS API GATEWAY, so here are the steps needed. In order to change your resource name you need to run 3 commands on the cli. One to get your API ID, one to get the Resource ID and one last command to change its name. First lets gonna find the ID of the desired API. Using the aws cli type the following command: aws apigateway get-rest-apis The API will return a json with an array of items containing all of your apis. Look into the name property to find the api that have the resource you need to change. Right above the name property you have the id property of your api. Take note of this id and run the following command with it to get the resource id. aws apigateway get-resources --rest-api-id 1010101010 Get the id matching the resource path that you are looking for to run the final command thats going to change your resource name. aws apigateway update-rest-api --rest-api-id 1010101010 --patch-operations op=replace,pat

Copy a file to a remote instance on AWS using SCP

Many times you gonna need to move a file from your local computer to a remote server or download a file from a remote instance just using the terminal. You can achieve that by using the scp command: scp -r -i file.pem ./file.csv ubuntu@IP:downloads Notice that your destination folder is specified the IP Address. In this case, the downlod folder in the remote server. If you need to copy/download a file from the remote server to your local machine, just have to switch scp -r -i file.pem ubuntu@IP:downloads/file.csv . The dot (.) being your current directory in linux.

Copy CSV file to Postgres using \copy

Log into your virtual instance. In my case, i will ssh into an ec2 instance using a pem file like this: ssh -i file.pem ubuntu@IP Next, log into the postgres client followed by your password. psql -U user -h hostname dbname Postgres make use of the COPY command to deal with large volume of data more efficiently. \copy table_name(field1,field2) FROM path_to_file_on_server.csv DELIMITER ';' When using the \copy command we do not use the quotes on the file name. A path to a csv file on the server could look like the following: /home/ubuntu/downloads/file.csv