s3cmd add lifecycle rule for object in bucket - amazon-web-services

I am using s3smd package in ubuntu for uploading files on aws.
Now i want to add lifecycle rule for different objects inside bucket.
I can see the commands from http://s3tools.org/usage
According to s3cmd git page(https://github.com/s3tools/s3cmd/pull/295)
I am using like this
s3cmd put --recursive ${TMP_PATH}${FILENAME}${DATESTAMP}.tar.gz s3://${S3BUCKET}/${S3PATH}day/
s3cmd expire s3://${S3BUCKET} --expiry-days=365 --expiry-prefix=log/
but keep getting error
Usage: s3cmd [options] COMMAND [parameters]
s3cmd: error: no such option: --expiry-days
i am unable to find working example for how to add expiry date/lifecycle rule for a object in bucket.
Let me know what i am doing wrong
Thank you

I realise this is an old question, but it appears on google, so worth answering.
Ubuntu (14.04) ships with an old version of s3cmd. You can check this by running
s3cmd --version
The best thing to do is to install it with pip, the python package manager.
sudo apt-get remove s3cmd && sudo apt-get install python-pip && pip install s3cmd
You may need to log out, then back in to allow your path to s3cmd to update. But after that if you
s3cmd --version
You should get a much later version. Your expire flag should now work fine.

Related

AWS CLI VERSION UPGRADE

I have installed AWS CLI latest version using "sudo pip install --upgrade awscli " .
this has successfully updated my aws cli version but for only root users, but for all remaining users , it is showing version as previous one only, If I run the command without sudo then its saying permission denied.
If my server has multiple linux users and want to update my aws cli version from 1.16.3 to 1.18.223 for all users, how can I do it ?
Please help me .
Thank in advance
You can adjust the path where you want to install, the binary.
Install the AWS CLI version 1 using the bundled installer with sudo
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle-1.18.223.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Just curious when you are upgrading the AWS Cli why not the latest which is backward compatible and probaly more options
Try not to install pip packages with sudo. Better use a Creating virtual environments

How to install AWS CLI for root user on Centos 7 - /usr/local/bin not in PATH for root user

When I install the AWS CLI for the root user on CENTOS 7, it installs it to /usr/local/bin as with other users. Problem is though, /usr/local/bin isn't in $PATH for the root user. At first I thought this was a bug in CENTOS, one that has been around for a very long time, but it's also possible its for reasons of security, I don't know.
What would be best practice then to install the AWS CLI for the root user?
To complement Chris'es answer, you can install the AWS CLI v2 in a folder visible to root, such as /usr/local/sbin as follows:
sudo yum install unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/sbin
then confirm with:
aws --version
which should produce:
aws-cli/2.0.44 Python/3.7.3 Linux/3.10.0-1127.el7.x86_64 exe/x86_64.centos.7
This appears to a bug logged in CentOS since 2012 in CentOS 6 but as of yet has not been fixed.
Regarding running AWS CLI as root, you can still run it by running /usr/local/bin/aws although I get that this is not ideal. Additionally you should try to avoid running AWS CLI as root if possible, instead run it as a named user.
According to the documentation you can use either --bin-dir or -b to specify a different bin directory so you could check a path that both root and named users have in their $PATH variable.
What worked for me was
sudo ./aws/install --bin-dir /usr/bin

Unable to install AWS SAM Cli on Mac

I am trying to install AWS SAM Cli on my Mac because I am trying to learn the AWS services. But I have installed the AWS cli successful using bundle. But when I tried to install the AWS SAM Cli as well. But it is not working. This is what I have done so far.
Run this command
pip install --user aws-sam-cli
Everything went fine.
Then I opened and edited the ~/.bash_profile. This is the content of the .bash_profile
export PATH=/Applications/MAMP/bin/php/php7.2.7/bin:$PATH
# Find your Python User Base path (where Python --user will install packages/scripts)
$ USER_BASE_PATH=$(python -m site --user-base)
# Update your preferred shell configuration
-- Standard bash --> ~/.bash_profile
-- ZSH --> ~/.zshrc
export PATH=$PATH:$USER_BASE_PATH/bin
Then I closed the terminal and run sam --version.
It is saying command not found. What is wrong with my installation?
The now recommended way to install SAM CLI is to use brew and honestly it's way better, saves you a lot of headaches, like the one you're facing now. See these instructions for details.

eks option is not available in AWS CLI. How to install it?

I have installed the AWS CLI around 6 moths back and upgraded using the following command today.
pip install --upgrade awscli
The current version on my Ubuntu 18.04 machine is:
aws-cli/1.14.44 Python/3.6.5 Linux/4.15.0-23-generic botocore/1.8.48
When I try aws eks command, I am getting the following error:
Invalid choice: 'eks', maybe you meant:
* es
Is my aws cli is upgraded properly or should I install something else for EKS service?
I had the same issue on El Capitan 10.11.6 and the only one worked solution was this:
sudo pip install awscli --ignore-installed six
Version 6 comes with distutils in El Capitan
Reference: https://github.com/aws/aws-cli#installation
Solutions mentioned did not resolve my issue - this link helped me out in figuring the issue.
aws --version
displayed a version which was not the latest. EKS was introduced with version 1.15.32 - which means my version did not know EKS at all. Uninstalling and reinstalling did not work either, path was referring to some older version previously installed somewhere else. The solution was following installation instructions here followed by updating the path variable
the issue cannot be resolved until the
aws --version command shows you any version less than 1.15.32.
The other solutions may be additional fixes needed afterwards, yet they will not work with an earlier version either.
Please check with the AWS region you configured for the AWS CLI you installed.
AWS EKS is available only on US East (N. Virginia) and US West (Oregon).
Do check it properly and configure the same for AWS CLI.
I faced the same issue because my current aws cli version was old (as shown below)
$aws --version
aws-cli/1.14.44 Python/3.6.8 Linux/4.15.0-58-generic botocore/1.8.4
Upgrading the awscli version helped to resolve the issue
$pip3 install --upgrade --user awscli
$aws --version
aws-cli/1.16.252 Python/3.6.8 Linux/4.15.0-58-generic botocore/1.12.242
Here is the link to upgrade awscli
https://docs.aws.amazon.com/cli/latest/userguide/install-linux-al2017.html
I was trying to connect to the cluster from a diff aws profile. So ideally we should use the same IAM profile for running kubectl from local so that the heptio-authenticator-aws will be happy.
This happens when we install aws-cli using apt packages as below.
sudo apt-get install awscli
because by default it will install 1.14 aws-cli version. Therefore my recommendation is to use pip3 to install aws-cli to your machine. It always installs the latest aws-cli version.
pip3 install --upgrade --user awscli
All this not worked for you then
pip uninstall awscli
sudo rm -rf /usr/local/aws
pip3 install awscli --upgrade --user
aws --version
aws-cli/1.18.39 Python/3.6.9 Linux/4.15.0-1065-aws botocore/1.15.39
if this is older version(aws-cli/1.18.39) then it won't work for you

How to uninstall aws-cli

I am trying to set up an "Amazon Elastic Container Registry" but I get the following error when using this command: aws ecr get-login --no-include-email --region us-west-2:
Unknown options: --no-include-email
The manual redirects me when this occurs to go to the following page, in order to update my aws cli. https://docs.aws.amazon.com/cli/latest/userguide/installing.html
Which in short means, call pip install awscli --upgrade --user. While that works, my cli is not updated. So I removed it at all pip uninstall awscli. But I still had the aws command available, also when I opened a new session in the terminal...
So I assume I haven't installed my aws cli via pip, but I can not figure out how it does is installed. Can anyone help me out and give me some directions to resolve this issue. So I can remove the current awscli, and install a new version via pip install awscli --upgrade --user
I had a similar issue. Answering in case someone else does too. I think I had originally installed it without pip like this:
https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html.
So you just need to uninstall it like this (as instructed in above link):
$ sudo rm -rf /usr/local/aws
$ sudo rm /usr/local/bin/aws
Then you can re-install it with pip3:
https://docs.aws.amazon.com/cli/latest/userguide/cli-install-macos.html
Basically:
pip3 install awscli --upgrade --user
Then add it to your path
export PATH=/Users/yourname/Library/Python/3.6/bin/:$PATH
On ubuntu :
sudo apt-get remove --auto-remove awscli
ln -s /home/ubuntu/.local/bin/aws /usr/bin/aws
Uninstall awscli.
pip uninstall awscli -y
I had the same issue, but unlike Morgan, I prefer to use Homebrew to maintain all my dependencies in a single place.
So what I did was:
1 - uninstall awscli (was installed with pip - python2)
$ sudo rm -rf /usr/local/aws
$ sudo rm /usr/local/bin/aws
2 - Install awscli using homebrew
$ brew install awscli
Homebrew will install awscli inside Cellar folder: /usr/local/Cellar/awscli
Note: I also have python3 installed through Hombrew.
Links:
Amazon-awscli: Amazon Install awscli
Homebrew-awscli: Homebrew Install awscli
Homebrew-python3: Homebrew Install python3
If you are using mac and used brew to install aws cli. Use brew uninstall awscli and try brew install awscli
First try to get the path of the installation by using this command in Linux or mac
which aws-cli
After you get the installation location try removing the directory by using
sudo rm -rf "/path resultant from previous command"
In case if someone has installed aws-cli using Snap,then following method might be helpful :
First, open the Linux terminal and run the following command in it:
sudo snap remove aws-cli
The basic command line to remove a snap package is
sudo snap remove < package >
You have to put the name of a specific application instead of < package >
Once you execute the command successfully, the terminal will ask you to enter the [sudo] password you put for the installation, but if you don’t have any password, press Enter to process it.
After completion of this procedure, you will see that aws-cli gets uninstalled from the system. However, the folder of aws is still present in the snap folder, so execute the following command to remove it:
sudo snap rm -r aws-cli
Remove respective bin & config files:
rm -rf /usr/local/bin/saml2aws
rm -rf ~/.aws/config
rm -rf ~/.aws/credentials
Reinstall using the 'install.sh' script
I tried this on linux and it seemed to work
sudo yum erase awscli
and get me to a place where when I run:
aws --version
zsh: command not found: aws