Skip to content

Commit

Permalink
Merge pull request #3 from bennycao/allow-custom-lifecycle-policy
Browse files Browse the repository at this point in the history
add optional lifecyclepolicy option
  • Loading branch information
bennycao authored Feb 8, 2019
2 parents 2ae061e + 8d6209f commit 743cbf1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ A [Buildkite plugin](https://buildkite.com/docs/agent/v3/plugins) to create and
steps:
- label: 'Main'
plugins:
seek-oss/create-ecr#v1.0.10:
name: "my-repo-name"
policy: "path/to/ecr-policy.json"
seek-oss/create-ecr:
name: 'my-repo-name'
repository-policy: 'path/to/repository-policy.json'
lifecycle-policy: 'path/to/lifecycle-policy.json'
command:
- echo hi
```
Params:
- name (required) - name of the ECR.
- policy (optional) - path in local repository to the policy file.
- repository-policy (optional) - path in local repository to the repository policy file.
- lifecycle-policy (optional) - path in local repository to the lifecycle policy file.
# License
Expand Down
17 changes: 9 additions & 8 deletions hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ upsert_ecr() {
aws ecr create-repository --repository-name "${repository_name}"
fi

policy_file="${BUILDKITE_PLUGIN_CREATE_ECR_POLICY:-''}"
echo "Policy file: ${policy_file}"
if [ "$policy_file" != "" ]; then
echo 'Setting ECR permissions'
repository_policy_file="${BUILDKITE_PLUGIN_CREATE_ECR_REPOSITORY_POLICY:-''}"
echo "Policy file: ${repository_policy_file}"
if [ "$repository_policy_file" != "" ]; then
echo 'Setting ECR repository policy'
aws ecr set-repository-policy \
--repository-name "${repository_name}" \
--policy-text "file://${policy_file}"
--policy-text "file://${repository_policy_file}"
fi

echo 'Setting ECR Lifecycle policy'
aws ecr put-lifecycle-policy \
echo 'Setting ECR Lifecycle policy'
lifecycle_policy_file="${BUILDKITE_PLUGIN_CREATE_ECR_LIFECYCLE_POLICY:-'$basedir/policies/default-lifecycle-policy.json'}"
aws ecr put-lifecycle-policy \
--repository-name "${repository_name}" \
--lifecycle-policy-text "file://$basedir/policies/default-lifecycle-policy.json"
--lifecycle-policy-text "file://${lifecycle_policy_file}"
}

$(aws ecr get-login --no-include-email)
Expand Down
4 changes: 3 additions & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ configuration:
properties:
name:
type: string
policy:
repository-policy:
type: string
lifecycle-policy:
type: string
required: ["name"]

0 comments on commit 743cbf1

Please sign in to comment.