noconfig, access key, secret key options

2011-08-02
2013-03-15
  • I'd like to make an enhancement requests:
    1. allow the passing of access key and secret options.
    2. Add a no config file option

    1. -
    In the very least we should be able to pass the access key and secret key to the s3cmd script so that they don't need to be stored in the .s3cfg file. This also makes it easier to jump between accounts through automation scripts without going through the config process for each.

    This is easily accomplished with adding the following code to the s3cmd script:
            optparser.add_option(      "-access_key", dest="access_key", help="AWS Access Key")
            optparser.add_option(      "-secret_key", dest="secret_key", help="AWS Secret Key")

    This has been tested with a .s3cfg config file with these values removed.

    2. -
    A noconfig option would allow the user to skip the configuration process and settle for the defaults. Of course without further enhancements to the command line options some of the functionality would be missing. However for the basic functionality of ls, put, get, etc. this makes it easy to spin up an EC2 instance, automatically wget s3cmd and immediately start using it without the configuration step.

    This can be done with the following code changes:

            optparser.add_option(      "-noconfig", dest="noconfig", help="Do not use the config file. access_key and secret_options will be required")

            if  options.noconfig:
                    cfg = Config()
            else :
                    ## Now finally parse the config file
                    if not options.config:
                            error(u"Can't find a config file. Please use -config option.")
                            sys.exit(1)

                    try:
                            cfg = Config(options.config)
                    except IOError, e:
                            if options.run_configure:
                                    cfg = Config()
                            else:
                                    error(u"%s: %s"  % (options.config, e.strerror))
                                    error(u"Configuration file not available.")
                                    error(u"Consider using -configure parameter to create one.")
                                    sys.exit(1)

    This has been tested with the following command line:
    ./s3cmd -noconfig=1 -access_key=ACCESS_KEY -secret_key=SECRET_KEY ls

    I'd like to see if this can get into next release.

    Thanks,
    Patrick

     
  • Vadim Zenin
    Vadim Zenin
    2012-02-15

    +1

     
  • Zander
    Zander
    2013-03-15

    +1
    I would like to see this too. I do not have the ability to run the --config option because it requires human interaction. (We have a Jenkins job that dynamically creates a build machine on the fly, and we ssh a bunch of commands on that machine, and we would like one of those commands to be "s3cmd". Hence, no human interaction.)