diff --git a/src/main/java/software/amazon/cloudformation/resource/ResourceTagging.java b/src/main/java/software/amazon/cloudformation/resource/ResourceTagging.java index 6984bc6..0d8a738 100644 --- a/src/main/java/software/amazon/cloudformation/resource/ResourceTagging.java +++ b/src/main/java/software/amazon/cloudformation/resource/ResourceTagging.java @@ -14,6 +14,9 @@ */ package software.amazon.cloudformation.resource; +import java.util.ArrayList; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Data; @@ -30,6 +33,7 @@ public class ResourceTagging { public static final String TAG_UPDATABLE = "tagUpdatable"; public static final String CLOUDFORMATION_SYSTEM_TAGS = "cloudFormationSystemTags"; public static final String TAG_PROPERTY = "tagProperty"; + public static final String TAG_PERMISSIONS = "permissions"; public static final ResourceTagging DEFAULT = new ResourceTagging(true); private boolean taggable; @@ -37,6 +41,7 @@ public class ResourceTagging { private boolean tagUpdatable; private boolean cloudFormationSystemTags; private JSONPointer tagProperty; + private List tagPermissions; public ResourceTagging(final boolean taggableValue) { this.taggable = taggableValue; @@ -44,6 +49,7 @@ public ResourceTagging(final boolean taggableValue) { this.tagUpdatable = taggableValue; this.cloudFormationSystemTags = taggableValue; this.tagProperty = new JSONPointer("/properties/Tags"); + this.tagPermissions = new ArrayList<>(); } public void resetTaggable(final boolean taggableValue) { diff --git a/src/main/java/software/amazon/cloudformation/resource/ResourceTypeSchema.java b/src/main/java/software/amazon/cloudformation/resource/ResourceTypeSchema.java index f941674..c0e6e61 100644 --- a/src/main/java/software/amazon/cloudformation/resource/ResourceTypeSchema.java +++ b/src/main/java/software/amazon/cloudformation/resource/ResourceTypeSchema.java @@ -166,6 +166,10 @@ public ResourceTypeSchema(Schema schema) { taggingValue.setCloudFormationSystemTags(Boolean.parseBoolean(value.toString())); } else if (key.equals(ResourceTagging.TAG_PROPERTY)) { taggingValue.setTagProperty(new JSONPointer(value.toString())); + } else if (key.equals(ResourceTagging.TAG_PERMISSIONS)) { + List tagPermissions = new ArrayList<>(); + ((List) value).forEach(p -> tagPermissions.add(p.toString())); + taggingValue.setTagPermissions(tagPermissions); } else { throw new ValidationException("Unexpected tagging metadata attribute", "tagging", "#/tagging/" + key); } diff --git a/src/main/resources/schema/provider.definition.schema.v1.json b/src/main/resources/schema/provider.definition.schema.v1.json index 5a4d0ac..6130be6 100644 --- a/src/main/resources/schema/provider.definition.schema.v1.json +++ b/src/main/resources/schema/provider.definition.schema.v1.json @@ -145,6 +145,13 @@ "description": "A reference to the Tags property in the schema.", "$ref": "http://json-schema.org/draft-07/schema#/properties/$ref", "default": "/properties/Tags" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + }, + "additionalItems": false } }, "required": [ diff --git a/src/test/java/software/amazon/cloudformation/resource/ResourceTaggingTest.java b/src/test/java/software/amazon/cloudformation/resource/ResourceTaggingTest.java index 9dd1834..ae4138b 100644 --- a/src/test/java/software/amazon/cloudformation/resource/ResourceTaggingTest.java +++ b/src/test/java/software/amazon/cloudformation/resource/ResourceTaggingTest.java @@ -16,6 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.util.ArrayList; + import org.everit.json.schema.JSONPointer; import org.junit.jupiter.api.Test; @@ -24,7 +26,7 @@ public class ResourceTaggingTest { public void testResetTaggable() { final ResourceTagging resourceTagging = new ResourceTagging(true, true, true, - true, new JSONPointer("/properties/tags")); + true, new JSONPointer("/properties/tags"), new ArrayList<>()); resourceTagging.resetTaggable(false); assertThat(resourceTagging.isTaggable()).isEqualTo(false); @@ -32,5 +34,6 @@ public void testResetTaggable() { assertThat(resourceTagging.isTagUpdatable()).isEqualTo(false); assertThat(resourceTagging.isCloudFormationSystemTags()).isEqualTo(false); assertThat(resourceTagging.getTagProperty().toString()).isEqualTo("/properties/tags"); + assertThat(resourceTagging.getTagPermissions().isEmpty()); } } diff --git a/src/test/java/software/amazon/cloudformation/resource/ResourceTypeSchemaTest.java b/src/test/java/software/amazon/cloudformation/resource/ResourceTypeSchemaTest.java index 77c6d45..c2beafc 100644 --- a/src/test/java/software/amazon/cloudformation/resource/ResourceTypeSchemaTest.java +++ b/src/test/java/software/amazon/cloudformation/resource/ResourceTypeSchemaTest.java @@ -427,6 +427,7 @@ public void schemaWithTagging_withValidConfiguration() { assertThat(schema.getTagging().isCloudFormationSystemTags()).isEqualTo(false); assertThat(schema.definesProperty("propertyB")).isTrue(); assertThat(schema.getTagging().getTagProperty()).asString().isEqualTo("/properties/propertyB"); + assertThat(schema.getTagging().getTagPermissions()).contains("test:permission"); } /** diff --git a/src/test/resources/valid-with-tagging-schema.json b/src/test/resources/valid-with-tagging-schema.json index 73f0562..9b84fa3 100644 --- a/src/test/resources/valid-with-tagging-schema.json +++ b/src/test/resources/valid-with-tagging-schema.json @@ -22,7 +22,10 @@ "tagOnCreate": true, "tagUpdatable": false, "cloudFormationSystemTags": false, - "tagProperty": "/properties/propertyB" + "tagProperty": "/properties/propertyB", + "permissions": [ + "test:permission" + ] }, "additionalProperties": false }