Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

v0.100.4

Latest
Compare
Choose a tag to compare
@gordonmleigh gordonmleigh released this 12 Nov 17:28
· 14 commits to main since this release

With this release I've rewritten the generation code to use the CloudFormation Resource Provider Schemas for better types. This version is supposed to be mostly compatible with previous versions.

Versioning Strategy

Going forward, the versioning strategy will change. Previously, the Resource Specification version was used to determine how to update the package version; i.e. if there was a breaking change in the Resource Specification version, then there would be a breaking change in this package version. I realised recently that AWS aren't using semantic versioning, and pretty much always increase the major version of the spec.

Breaking Change

ResourceType enum replaced

The ResourceType enum is now a const object:

export const ResourceType = {
  ACMPCACertificateProps: "AWS::ACMPCA::Certificate",
  ACMPCACertificateAuthorityProps: "AWS::ACMPCA::CertificateAuthority",
  ACMPCAPermissionProps: "AWS::ACMPCA::Permission",
  APSRuleGroupsNamespaceProps: "AWS::APS::RuleGroupsNamespace",
  APSWorkspaceProps: "AWS::APS::Workspace",
  AccessAnalyzerAnalyzerProps: "AWS::AccessAnalyzer::Analyzer",
  AmazonMQBrokerProps: "AWS::AmazonMQ::Broker",
  AmazonMQConfigurationProps: "AWS::AmazonMQ::Configuration",
  // ... omitted
};

There is also a corresponding type, defined as the union of possible value types:

export type ResourceType = (typeof ResourceType)[keyof typeof ResourceType];

These definitions are mostly equivalent to the enum declaration, except that the members cannot be used as a type:

// ❌ this won't work:
type Props = AttributeTypeFor<ResourceType.LambdaFunction>;

// ✅ either of these will:
type Props = AttributeTypeFor<typeof ResourceType.LambdaFunction>;
type Props = AttributeTypeFor<"AWS::Lambda::Function">;

The reason for the change is that string enums are intentionally opaque: an enum type is only assignable to another enum type that has the same name and exactly the same members. This means that if two modules use a different version of this package, then the resource types will not be assignable. This would then force you to keep the version of this package aligned across all dependencies to avoid problems.

What's happening to v1.x?

Since there are people depending on this package, I've put it back to the way it was (apart from using a lot of the new code to generate the types). I'll publish the v1 code as a new package soon.