Search for Well Architected Advice
< All Topics
Print

Provide service contracts per API

Service contracts are documented agreements between API producers and consumers, defined in a machine-readable API definition. These contracts help clarify expectations and ensure consistency in interactions between services. A contract versioning strategy allows consumers to continue using the existing API while planning their migration to newer versions when ready. Producer deployment can happen anytime as long as the service contract is maintained, allowing flexibility in technology choices for the service teams while meeting consumer needs.

Establish service contract champions in each team: Assign service contract champions within each workload team to oversee the creation, maintenance, and versioning of API contracts. These champions ensure that APIs are well-documented, follow agreed-upon standards, and meet the needs of both producers and consumers.

Provide training on API contracts and versioning: Train builder teams on best practices for creating and maintaining service contracts, including how to use machine-readable definitions like OpenAPI. Training should also include strategies for managing versioning, backward compatibility, and consumer communication. Proper training helps teams build reliable APIs that are easy to integrate and evolve over time.

Develop service contract guidelines and standards: Create clear guidelines for defining, maintaining, and versioning service contracts. These guidelines should cover the use of standards like OpenAPI, best practices for defining contract changes, and maintaining backward compatibility. Documented standards help ensure consistency across teams and improve the reliability of API interactions.

Integrate contract validation into CI/CD pipelines: Integrate API contract validation checks into CI/CD pipelines to ensure that new versions of services adhere to their contracts. Automated validation can verify that changes do not break existing contracts and ensure that new versions maintain backward compatibility, reducing the risk of disruptions for consumers.

Define automated guardrails for service contracts: Use automated tools to enforce adherence to API contracts and ensure consistency between API definitions and implementations. Tools like AWS API Gateway, Swagger, and AWS Lambda can help enforce service contracts, while versioning tools can guide the evolution of the API. Automated guardrails help maintain compliance with service contracts throughout the development and deployment processes.

Foster a culture of transparency in API design: Encourage builder teams to prioritize transparency and consumer communication when designing APIs. Recognize and reward teams that maintain clear, well-documented contracts and versioning strategies that facilitate smooth transitions for consumers. Foster open discussions about service contract management to promote continuous improvement.

Conduct regular contract reviews: Schedule regular reviews of API contracts to ensure that they align with business requirements and consumer needs. These reviews should assess the effectiveness of versioning strategies and ensure that all changes are well-communicated to API consumers. Regular reviews help maintain the reliability and usability of APIs as they evolve.

Leverage automation for consistent API contract management: Use Infrastructure as Code (IaC) tools like AWS CloudFormation or AWS CDK to automate the deployment of API contracts and versioning. Automating these processes helps prevent manual errors, ensures consistent application of contracts across environments, and makes it easier to maintain versioning.

Provide dashboards for contract visibility and versioning: Use dashboards to provide visibility into API contracts, current versions, and compatibility with consumers. Tools like Amazon API Gateway, AWS CloudWatch, and Swagger can help track the status and usage of different API versions. Dashboards help builder teams proactively manage contract adherence and ensure smooth transitions for API consumers.

Supporting Questions

  • How do you ensure that builder teams define and maintain service contracts for their APIs?
  • What mechanisms are in place to validate that changes to APIs maintain backward compatibility with existing contracts?
  • How do you align API design and versioning practices with organizational standards for reliability and consumer usability?

Roles and Responsibilities

Service Contract Champion (within Builder Team)

Responsibilities:

  • Define, document, and maintain API contracts between producers and consumers.
  • Oversee contract versioning to ensure backward compatibility and effective consumer migration.

Application Developer

Responsibilities:

  • Implement features while adhering to service contracts and using the specified API definitions.
  • Use automated tools to validate API changes and ensure they comply with the established contracts.

Operations Team Member

Responsibilities:

  • Assist builder teams with managing service contracts, versioning, and consumer communication.
  • Provide guidance and training to ensure that service contracts are maintained according to best practices.

Artifacts

API Contract Guidelines and Standards: A document outlining best practices for defining, maintaining, and versioning service contracts using machine-readable API definitions.

Training Resources for API Contracts: Hands-on labs, workshops, and documentation to help teams understand how to create and maintain service contracts effectively.

Automated Contract Validation Configurations: Scripts and configurations that help automate the validation of API contracts across environments.

Relevant AWS Services

Training and Awareness Tools:

  • AWS Skill Builder and AWS Well-Architected Labs: Resources for learning about creating and maintaining service contracts, versioning, and consumer communication.
  • AWS Trusted Advisor: Provides insights into API configurations and recommendations for improving the consistency and reliability of API interactions.

Service Contract Management and Guardrails:

  • AWS API Gateway: Manages the implementation of service contracts and versioning for APIs, ensuring adherence to defined standards.
  • Swagger (OpenAPI): Defines and documents API contracts in a machine-readable format, making it easier to manage versions and maintain consumer clarity.
  • AWS Lambda: Provides flexibility in implementing APIs while maintaining compliance with service contracts.

Monitoring and Visibility Tools:

  • Amazon CloudWatch: Tracks the usage of API versions and monitors adherence to service contracts, providing alerts for non-compliance.
  • AWS API Gateway: Helps manage API versions, ensuring smooth transitions for consumers by providing consistent access across versions.
  • AWS CloudFormation: Codifies API configurations to automate the deployment and management of service contracts and ensure consistency across environments.
Table of Contents