Skip to content

Commit

Permalink
feat: create prefix for move based on contexpath
Browse files Browse the repository at this point in the history
  • Loading branch information
roleyfoley committed Feb 4, 2021
1 parent 06360c0 commit e57fd23
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 27 deletions.
38 changes: 27 additions & 11 deletions hamlet/s3support/extensions/s3_inventory_copy_batch/extension.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,35 @@

[#macro shared_extension_s3_inventory_copy_batch_deployment_setup occurrence ]

[#local s3PathConfig = ((_context.DefaultEnvironment["S3_PATH"])!"")?eval]

[#local s3DestinationPrefix = ""]
[#if s3PathConfig.Prefix.Enabled ]
[#local s3DestinationPrefix = getContextPath(occurrence, s3PathConfig.Prefix.Path) ]
[#if s3PathConfig.Prefix.Path.Style == "path" ]
[#local s3DestinationPrefix = s3DestinationPrefix?ensure_ends_with("/") ]
[/#if]
[/#if]

[#local s3DestinationSuffix = ""]
[#if s3PathConfig.Suffix.Enabled ]
[#local s3DestinationSuffix = getContextPath(occurrence, s3PathConfig.Suffix.Path) ]
[#if s3PathConfig.Suffix.Path.Style == "path" ]
[#local s3DestinationSuffix = s3DestinationSuffix?ensure_ends_with("/") ]
[/#if]
[/#if]


[@Settings
[
"DESTINATION_BUCKET_NAME"
] +
valueIfContent(
[ "S3_DESTINATION_PREFIX" ],
(_context.DefaultEnvironment["S3_DESTINATION_PREFIX"])!"",
[]
) +
valueIfContent(
[ "S3_DESTINATION_SUFFIX" ],
(_context.DefaultEnvironment["S3_DESTINATION_SUFFIX"])!"",
[]
)
]
/]

[@Settings
{
"S3_DESTINATION_PREFIX" : s3DestinationPrefix,
"S3_DESTINATION_SUFFIX" : s3DestinationSuffix
}
/]
[/#macro]
54 changes: 38 additions & 16 deletions hamlet/s3support/modules/s3_inventory_copy/module.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,55 @@
{
"Names" : "id",
"Description" : "A unique id for this instance of the api",
"Type" : STRING_TYPE,
"Types" : STRING_TYPE,
"Mandatory" : true
},
{
"Names" : "tier",
"Description" : "The tier the components will belong to",
"Type" : STRING_TYPE,
"Types" : STRING_TYPE,
"Mandatory" : true
},
{
"Names" : "instance",
"Description" : "The instance id of the components",
"Type" : STRING_TYPE,
"Types" : STRING_TYPE,
"Default" : "default"
},
{
"Names" : "s3KeyPrefix",
"Description" : "A prefix to append to all keys in the report when copying",
"Type" : STRING_TYPE,
"Default" : ""
"Description" : "Creates a key prefix based on the deployment context",
"Children" : [
{
"Names" : "Enabled",
"Types" : BOOLEAN_TYPE,
"Default" : true
},
{
"Names" : "Path",
"AttributeSet" : CONTEXTPATH_ATTRIBUTESET_TYPE
}
]
},
{
"Names" : "s3KeySuffix",
"Description" : "A suffix to append to all keys in the report when copying",
"Type" : STRING_TYPE,
"Default" : ""
"Description" : "Creates a key suffix based on the deployment context",
"Children" : [
{
"Names" : "Enabled",
"Types" : BOOLEAN_TYPE,
"Default" : false
}
{
"Names" : "Path",
"AttributeSet" : CONTEXTPATH_ATTRIBUTESET_TYPE
}
]
},
{
"Names" : "s3InventoryPrefix",
"Description" : "The prefix to use for inventory generation on the source bucket",
"Type" : STRING_TYPE,
"Types" : STRING_TYPE,
"Default" : "s3_inventory_copy/"
},
{
Expand All @@ -54,25 +72,25 @@
{
"Names" : "s3InventoryProfileSuffix",
"Description" : "The suffix ( added to the id ) for the deployment profile which configures the userpool client",
"Type" : STRING_TYPE,
"Types" : STRING_TYPE,
"Default" : "_s3inventorycopy"
},
{
"Names" : "lambdaImageUrl",
"Description" : "The url to the lambda zip image",
"Type" : STRING_TYPE,
"Types" : STRING_TYPE,
"Default" : "https://github.com/hamlet-io/lambda-s3-support/releases/download/v0.0.9/s3-inventory-copy.zip"
},
{
"Names" : "lambdaImageHash",
"Description" : "The sha1 hash of the lambda zip image",
"Type" : STRING_TYPE,
"Types" : STRING_TYPE,
"Default" : "eec63deecde1ddc737d8e951eef8fe9b410a9ad4"
},
{
"Names" : "batchPriorty",
"Description" : "The priority of the s3 batch call - Highest wins",
"Type" : NUMBER_TYPE,
"Types" : NUMBER_TYPE,
"Default" : 100
}
]
Expand Down Expand Up @@ -126,8 +144,12 @@
"Scope" : "Products",
"Namespace" : s3BatchSettingsNamespace,
"Settings" : {
"S3_DESTINATION_PREFIX" : s3KeyPrefix,
"S3_DESTINATION_SUFFIX" : s3KeySuffix
"s3_path": {
"Value": {
"Prefix" : s3KeyPrefix,
"Suffix" : s3KeySuffix
}
}
}
}
]
Expand Down

0 comments on commit e57fd23

Please sign in to comment.