diff --git a/README.md b/README.md index b73d1d1..0548fd4 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,10 @@ 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 ``` @@ -20,7 +21,8 @@ steps: 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 diff --git a/hooks/pre-command b/hooks/pre-command index b2c3776..e797a34 100644 --- a/hooks/pre-command +++ b/hooks/pre-command @@ -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) diff --git a/plugin.yaml b/plugin.yaml index cd9b45b..68cbd35 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -7,6 +7,8 @@ configuration: properties: name: type: string - policy: + repository-policy: + type: string + lifecycle-policy: type: string required: ["name"]