jpillora / grunt-aws

A Grunt interface into the Amazon Node.JS SDK
171 stars 44 forks source link

Options for different environments #52

Closed anfuerer closed 8 years ago

anfuerer commented 9 years ago

Would it be possible to extend the config in a way that different environments can be supported?

I'm thinking about sth like the following:

/*..*/
  dev: {
    s3: {
        options: {
            accessKeyId: "<%= aws.accessKeyId %>",
            secretAccessKey: "<%= aws.secretAccessKey %>",
            bucket: "my-dev-bucket"
        }
      }
  },
  staging: {
    s3: {
        options: {
            accessKeyId: "<%= aws.accessKeyId %>",
            secretAccessKey: "<%= aws.secretAccessKey %>",
            bucket: "my-staging-bucket"
        }
      }
  },
  prod: {
    s3: {
        options: {
            accessKeyId: "<%= aws.accessKeyId %>",
            secretAccessKey: "<%= aws.secretAccessKey %>",
            bucket: "my-prod-bucket"
        }
      }
  }
/* .. */
}

Then the s3 task can be run as follows

grunt s3 --target=dev
jpillora commented 9 years ago

It is indeed possible

s3 is a multitask so you can provide task options and then also provide target level options which override task options

s3: {
  options: {
    accessKeyId: "<%= aws.accessKeyId %>",
    secretAccessKey: "<%= aws.secretAccessKey %>"
  },
  //then create some targets..
  staging: {
    options: {
      bucket: "my-staging-bucket"
    },
    cwd: "build/",
    src: "**"
  }

Then the s3 task can be run as follows

grunt s3:staging

Edit: Hit submit early

anfuerer commented 8 years ago

@jpillora all clear. thanks for the hint.