[ch5082] | Piyush | Add support for provisioning multiple s3 bucket with expiration rules
This commit is contained in:
110
bindata.go
110
bindata.go
@@ -2,6 +2,8 @@
|
||||
// sources:
|
||||
// templates/aws-roles-tf/deploy.sh
|
||||
// templates/aws-roles-tf/main.tf
|
||||
// templates/aws-s3-bucket-tf/deploy.sh
|
||||
// templates/aws-s3-bucket-tf/main.tf
|
||||
// templates/rds-tf/deploy.sh
|
||||
// templates/rds-tf/main.tf
|
||||
|
||||
@@ -111,8 +113,8 @@ func bindataTemplatesAwsrolestfDeploysh() (*asset, error) {
|
||||
name: "templates/aws-roles-tf/deploy.sh",
|
||||
size: 374,
|
||||
md5checksum: "",
|
||||
mode: os.FileMode(436),
|
||||
modTime: time.Unix(1585549780, 0),
|
||||
mode: os.FileMode(420),
|
||||
modTime: time.Unix(1584392515, 0),
|
||||
}
|
||||
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
@@ -154,8 +156,86 @@ func bindataTemplatesAwsrolestfMaintf() (*asset, error) {
|
||||
name: "templates/aws-roles-tf/main.tf",
|
||||
size: 735,
|
||||
md5checksum: "",
|
||||
mode: os.FileMode(436),
|
||||
modTime: time.Unix(1585549780, 0),
|
||||
mode: os.FileMode(420),
|
||||
modTime: time.Unix(1582736085, 0),
|
||||
}
|
||||
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _bindataTemplatesAwss3buckettfDeploysh = []byte(
|
||||
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\xcd\x31\x0e\x82\x40\x10\x85\xe1\x7e\x4f\xf1\x0c\x35\x70\x0a\x2f\x60" +
|
||||
"\x63\x3d\xae\x43\xd8\x08\x3b\x9b\x99\x41\x20\xc0\xdd\xed\x0c\x85\x89\xe5\x4b\xde\x97\xbf\xba\xb4\x8f\x94\x5b\xeb" +
|
||||
"\x43\xa8\xc0\x4b\x72\xcc\x3d\x67\x50\x5e\x11\x65\x1c\x29\x3f\xd1\x51\x1a\x2c\x18\x3b\x6a\x0e\xc1\x59\x95\x3a\xd1" +
|
||||
"\x11\x29\x27\x3f\xcd\x59\xf4\x65\x85\x22\xc3\x78\xe0\xe8\xd8\x36\x34\xd7\xc5\x95\x6e\x6c\x32\x69\x64\x6b\xee\xdf" +
|
||||
"\xcf\x71\x60\xdf\xf1\x4b\x67\x9e\xff\xd1\x53\x95\x4a\x19\x56\xd4\x34\xb9\xd4\x54\x8a\xca\x9b\x3f\x01\x00\x00\xff" +
|
||||
"\xff\x2a\xc1\x14\x78\xd3\x00\x00\x00")
|
||||
|
||||
func bindataTemplatesAwss3buckettfDeployshBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
_bindataTemplatesAwss3buckettfDeploysh,
|
||||
"templates/aws-s3-bucket-tf/deploy.sh",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
func bindataTemplatesAwss3buckettfDeploysh() (*asset, error) {
|
||||
bytes, err := bindataTemplatesAwss3buckettfDeployshBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{
|
||||
name: "templates/aws-s3-bucket-tf/deploy.sh",
|
||||
size: 211,
|
||||
md5checksum: "",
|
||||
mode: os.FileMode(420),
|
||||
modTime: time.Unix(1586084831, 0),
|
||||
}
|
||||
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _bindataTemplatesAwss3buckettfMaintf = []byte(
|
||||
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x91\x4f\x6b\xf3\x30\x0c\xc6\xef\xf9\x14\x26\x77\x3b\xbc\xf4\x56\x28" +
|
||||
"\xbc\x2b\xeb\x65\x87\x31\x96\xc1\x8e\xc5\x75\x95\xc4\x24\xb1\x82\x2c\xf7\x0f\x9d\xbf\xfb\x70\x92\x8e\x95\xf6\x30" +
|
||||
"\xdd\xa2\x3c\x7a\xf4\xd3\x63\x06\x22\x5d\x21\xf5\xe2\x92\x09\xb1\xd3\xa6\x05\xb7\x17\xb9\x5f\xe4\x63\x43\x88\x5d" +
|
||||
"\x30\x2d\xb0\xb8\xad\x95\xc8\x2f\x17\xa1\x4a\xd6\x0c\x25\x23\xc1\x7a\x1a\x54\xeb\x51\xfd\xaa\x7b\x10\x31\xe6\xa3" +
|
||||
"\x01\x41\x6d\xd1\xdd\x1b\xe8\x41\x7a\x0c\xdc\xc8\x7f\x93\xae\x85\xb3\xb8\xab\x55\x42\x91\x13\x83\x9f\x74\x47\xa4" +
|
||||
"\xd6\x0f\xda\xc0\xb6\x85\xf3\x76\x20\xa8\xec\xe9\x56\x57\x24\xb6\xcd\x89\x49\xbf\x83\xc7\x40\x06\xbc\xda\xb8\x83" +
|
||||
"\x25\x74\x3d\x38\x16\x31\x8e\x8a\x67\x18\x3a\x3c\xa7\x8e\x9a\x81\xe5\x83\x76\x19\xaa\xb4\xe0\x7a\xcd\x40\x58\xd9" +
|
||||
"\x0e\xfe\x18\xc7\xd3\x67\xf9\x36\x0f\x5c\x0d\xb4\xe9\x1e\x9e\x39\xb1\x4b\x3c\x3a\x20\x59\x85\xae\x93\x06\x1d\x13" +
|
||||
"\x76\x69\x2c\x66\x31\xcb\x7a\xdc\x87\x0e\x6e\x02\x19\xdf\x68\x3a\xf1\x97\x55\x6d\x79\xb9\xf4\xbe\x59\x16\x45\x6d" +
|
||||
"\xf9\x7f\x6d\xb9\x09\x3b\x65\xfa\xbd\x72\xfa\x60\x25\x83\x69\x94\x75\xc5\xf8\x61\x5d\x45\xba\xd0\x47\x2f\x7f\x6c" +
|
||||
"\x55\x6d\x39\x2d\xf5\x8b\xed\xbc\x27\xb9\x3e\xc8\xb4\x5c\xac\xe7\xff\x5f\xa2\x0f\x9e\x3f\xf0\xc5\xa3\x13\x31\xd1" +
|
||||
"\x7e\x07\x00\x00\xff\xff\xf6\x75\x74\xaf\x58\x02\x00\x00")
|
||||
|
||||
func bindataTemplatesAwss3buckettfMaintfBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
_bindataTemplatesAwss3buckettfMaintf,
|
||||
"templates/aws-s3-bucket-tf/main.tf",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
func bindataTemplatesAwss3buckettfMaintf() (*asset, error) {
|
||||
bytes, err := bindataTemplatesAwss3buckettfMaintfBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{
|
||||
name: "templates/aws-s3-bucket-tf/main.tf",
|
||||
size: 600,
|
||||
md5checksum: "",
|
||||
mode: os.FileMode(420),
|
||||
modTime: time.Unix(1586084831, 0),
|
||||
}
|
||||
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
@@ -191,8 +271,8 @@ func bindataTemplatesRdstfDeploysh() (*asset, error) {
|
||||
name: "templates/rds-tf/deploy.sh",
|
||||
size: 449,
|
||||
md5checksum: "",
|
||||
mode: os.FileMode(436),
|
||||
modTime: time.Unix(1585715612, 0),
|
||||
mode: os.FileMode(420),
|
||||
modTime: time.Unix(1586084879, 0),
|
||||
}
|
||||
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
@@ -241,8 +321,8 @@ func bindataTemplatesRdstfMaintf() (*asset, error) {
|
||||
name: "templates/rds-tf/main.tf",
|
||||
size: 1578,
|
||||
md5checksum: "",
|
||||
mode: os.FileMode(436),
|
||||
modTime: time.Unix(1585825744, 0),
|
||||
mode: os.FileMode(420),
|
||||
modTime: time.Unix(1586084879, 0),
|
||||
}
|
||||
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
@@ -314,10 +394,12 @@ func AssetNames() []string {
|
||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||
//
|
||||
var _bindata = map[string]func() (*asset, error){
|
||||
"templates/aws-roles-tf/deploy.sh": bindataTemplatesAwsrolestfDeploysh,
|
||||
"templates/aws-roles-tf/main.tf": bindataTemplatesAwsrolestfMaintf,
|
||||
"templates/rds-tf/deploy.sh": bindataTemplatesRdstfDeploysh,
|
||||
"templates/rds-tf/main.tf": bindataTemplatesRdstfMaintf,
|
||||
"templates/aws-roles-tf/deploy.sh": bindataTemplatesAwsrolestfDeploysh,
|
||||
"templates/aws-roles-tf/main.tf": bindataTemplatesAwsrolestfMaintf,
|
||||
"templates/aws-s3-bucket-tf/deploy.sh": bindataTemplatesAwss3buckettfDeploysh,
|
||||
"templates/aws-s3-bucket-tf/main.tf": bindataTemplatesAwss3buckettfMaintf,
|
||||
"templates/rds-tf/deploy.sh": bindataTemplatesRdstfDeploysh,
|
||||
"templates/rds-tf/main.tf": bindataTemplatesRdstfMaintf,
|
||||
}
|
||||
|
||||
//
|
||||
@@ -377,6 +459,10 @@ var _bintree = &bintree{Func: nil, Children: map[string]*bintree{
|
||||
"deploy.sh": {Func: bindataTemplatesAwsrolestfDeploysh, Children: map[string]*bintree{}},
|
||||
"main.tf": {Func: bindataTemplatesAwsrolestfMaintf, Children: map[string]*bintree{}},
|
||||
}},
|
||||
"aws-s3-bucket-tf": {Func: nil, Children: map[string]*bintree{
|
||||
"deploy.sh": {Func: bindataTemplatesAwss3buckettfDeploysh, Children: map[string]*bintree{}},
|
||||
"main.tf": {Func: bindataTemplatesAwss3buckettfMaintf, Children: map[string]*bintree{}},
|
||||
}},
|
||||
"rds-tf": {Func: nil, Children: map[string]*bintree{
|
||||
"deploy.sh": {Func: bindataTemplatesRdstfDeploysh, Children: map[string]*bintree{}},
|
||||
"main.tf": {Func: bindataTemplatesRdstfMaintf, Children: map[string]*bintree{}},
|
||||
|
||||
17
main.go
17
main.go
@@ -99,6 +99,23 @@ func main() {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "s3-buckets",
|
||||
Usage: "Provision s3 buckets",
|
||||
Action: func(c *cli.Context) error {
|
||||
manifest, err := parseManifest(c.String("manifest"))
|
||||
if err != nil {
|
||||
log.Fatalf("\nErr: %v", err)
|
||||
return err
|
||||
}
|
||||
err = provisionResource("s3", "aws-s3-bucket-tf", manifest, c.Bool("template-only"))
|
||||
if err != nil {
|
||||
log.Fatalf("\nErr: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,21 @@
|
||||
},
|
||||
"s3_buckets": [
|
||||
{
|
||||
"bucket_name": "navi-bucket-test-1",
|
||||
"acl": "private",
|
||||
"lifecycle_rule": {
|
||||
"enabled": false,
|
||||
"expiration": 1
|
||||
},
|
||||
"anonymizedBucketName": "navi-bucket-test-1",
|
||||
"bucketTag": "customer-uploads",
|
||||
"lifecycleRules": [
|
||||
{
|
||||
"enabled": true,
|
||||
"expiration": {
|
||||
"days": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "navi-bucket-test-2",
|
||||
"expiration_days": 1
|
||||
"anonymizedBucketName": "navi-bucket-test-2",
|
||||
"bucketTag": "document-uploads",
|
||||
"lifecycleRules": []
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
16
types.go
16
types.go
@@ -19,7 +19,7 @@ type ExtraResources struct {
|
||||
Workspace string
|
||||
Database Database `json:"database"`
|
||||
ServiceRole ServiceRole `json:"aws_access"`
|
||||
S3Buckets []S3Bucket `json:s3_buckets`
|
||||
S3Buckets []S3Bucket `json:"s3_buckets"`
|
||||
}
|
||||
|
||||
//We provide defaults in respective terraforms instead of here to keep all values at one place
|
||||
@@ -55,6 +55,16 @@ type StateStoreBackend struct {
|
||||
}
|
||||
|
||||
type S3Bucket struct {
|
||||
BucketName string `json:"name"`
|
||||
ExpirationDays string `json:expiration_days`
|
||||
BucketName string `json:"anonymizedBucketName"`
|
||||
BucketTag string `json:"bucketTag"`
|
||||
LifecycleRules []LifecycleRule `json:"lifecycleRules"`
|
||||
}
|
||||
|
||||
type LifecycleRule struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
ObjectExpiration ObjectExpiration `json:"expiration"`
|
||||
}
|
||||
|
||||
type ObjectExpiration struct {
|
||||
Days int `json:"days"`
|
||||
}
|
||||
Reference in New Issue
Block a user