Skip to content

Commit

Permalink
Warn for service missing tagEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich committed Nov 7, 2024
1 parent 37e0dec commit 8947155
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,23 @@ public List<ValidationEvent> validate(Model model) {
List<ValidationEvent> events = new LinkedList<>();
TopDownIndex topDownIndex = TopDownIndex.of(model);
AwsTagIndex tagIndex = AwsTagIndex.of(model);
for (ServiceShape service : model.getServiceShapesWithTrait(TagEnabledTrait.class)) {
for (ServiceShape service : model.getServiceShapes()) {
for (ResourceShape resource : topDownIndex.getContainedResources(service)) {
boolean resourceLikelyTaggable = false;
if (resource.hasTrait(TaggableTrait.class)) {
events.addAll(validateResource(model, resource, service, tagIndex));
} else if (resource.hasTrait(ArnTrait.class) && tagIndex.serviceHasTagApis(service.getId())) {
resourceLikelyTaggable = true;
} else if (resource.hasTrait(ArnTrait.class) && tagIndex.serviceHasTagApis(service)) {
// If a resource does not have the taggable trait, but has an ARN, and the service has tag
// operations, it is most likely a mistake.
events.add(warning(resource, "Resource is likely missing `aws.api#taggable` trait."));
resourceLikelyTaggable = true;
}

// It's possible the resource was marked as taggable but the service isn't tagEnabled.
if (resourceLikelyTaggable && !service.hasTrait(TagEnabledTrait.class)) {
events.add(warning(service, "Service has resources with `aws.api#taggable` applied but does not "
+ "have the `aws.api#tagEnabled` trait."));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
[WARNING] example.weather#Weather: Service marked `aws.api#TagEnabled` is missing an operation named 'UntagResource.' | ServiceTagging
[WARNING] example.weather#City: Suggested tag property name is '[T|t]ags'. | TagResourcePropertyName
[DANGER] example.weather#UpdateCity: Update and put resource lifecycle operations should not support updating tags because it is a privileged operation that modifies access. | TaggableResource
[WARNING] example.weather#Weather2: Service has resources with `aws.api#taggable` applied but does not have the `aws.api#tagEnabled` trait. | TaggableResource
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ service Weather {
operations: [GetCurrentTime]
}

service Weather2 {
version: "2006-03-01",
resources: [City]
}

structure Tag {
key: String
value: String
Expand Down

0 comments on commit 8947155

Please sign in to comment.