serverless-plugin-get-resource-id

0.1.1 • Public • Published

serverless-plugin-get-resource-id

main function

  • You can get the ID of an AWS :: ApiGateway resource by name or other key.
  • If you have an AWS :: ApiGateway :: deploy resource, add a timestamp to the logical ID value so you can deploy RestApi per serverless deployments.

Installation

$ npm i serverless-plugin-get-resource-id

add the plugin to serverless.yml

# serverless.yml
plugins:
  - serverless-plugin-get-resource-id

Configuration

Get Resource Id by Key

For each id value in the resource file:

  • Variable.apiGateway.{ResourceType}.id

Supported resource items:

  • 'AWS::ApiGateway::RestApi'
  • 'AWS::ApiGateway::ApiKey'
  • 'AWS::ApiGateway::Resource'
Resources:
  #Api Key Id
  ApiGatewayUsagePlanKey:
    Type: AWS::ApiGateway::UsagePlanKey
    DependsOn:
      - ApiGatewayUsagePlan
    Properties:
      KeyId: Variable.apiGateway.ApiKey.id
      KeyType: API_KEY
      UsagePlanId: !Ref ApiGatewayUsagePlan
  #Rest Api and Root Resource Id
  ApiGatewayResourceOne:
    Type: 'AWS::ApiGateway::Resource'
    Properties:
      ParentId: Variable.apiGateway.Resource.id
      PathPart: One
      RestApiId: Variable.apiGateway.RestApi.id
# custom.apiGateway.(ApiKey / RestApi / Resource).name
custom:
  apiGateway:
    RestApi:
      name: apiGatewayName
    ApiKey:
      name: apiKeyName
    Resource:
      name: / #Root Resource

Add Timestamp to Deployment

Adding a timestamp to 'AWS::ApiGateway::Deployment' is automatically applied if you have a Deployment resource

Package Sidebar

Install

npm i serverless-plugin-get-resource-id

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

8.56 kB

Total Files

4

Last publish

Collaborators

  • hanbyul