Skip to content

carnei-ro/kong-simple-aws-proxy

Repository files navigation

Kong Simple AWS Proxy

Description

summary: kong plugin to modify and assing requests (v4) for aws

Plugin Priority

Priority: 751

Plugin Version

Version: 0.0.8-0

config

name type required validations default
aws_key string
false
aws_secret string
false
body_service_key string
true
AWSService
body_payload_key string
true
RequestPayload
body_region_key string
true
AWSRegion
override_path_via_body boolean
false
false
api_prefix boolean
false
false
force_content_type_amz_json boolean
false
false
body_path_key string
false
RequestPath
override_body array of strings
false
- match: ^[^:]+:.*$
override_headers array of strings
false
- match: ^[^:]+:.*$
querystring_to_payload array of strings
false
- match: ^[^:]+:.*$
body_as_message_for_sns_sqs boolean
false
true
message_attributes_from_payload array of records**
false

record** of message_attributes_from_payload

name type required validations default
attribute_name string
true
payload_path string
true
nasted_path boolean
true
false
fallback_value string
false
attribute_data_type string
true
- one_of:
- String
- String.Array
- Number
- Binary
String
erase_from_payload boolean
true
false

Default Values

plugins:
  - name: kong-simple-aws-proxy
    enabled: true
    config:
      aws_key: ''
      aws_secret: ''
      body_service_key: AWSService
      body_payload_key: RequestPayload
      body_region_key: AWSRegion
      override_path_via_body: false
      api_prefix: false
      force_content_type_amz_json: false
      body_path_key: RequestPath
      override_body: [] # ["bodyKey:value"]
      override_headers: [] # ["headerName:value"]
      querystring_to_payload: [] # ["qsName:payloadKey"]
      body_as_message_for_sns_sqs: true
      message_attributes_from_payload:
        - attribute_name: ''
          payload_path: ''
          nasted_path: false
          fallback_value: ''
          attribute_data_type: String
          erase_from_payload: false

Use

Configure plugin - SQS/SNS (maybe others)

plugins:
- name: kong-simple-aws-proxy
  config:
    override_path_via_body: true # If false - Path from "Service" object - Needed if body contains RequestPath
    override_body:
    - Action=SendMessage # To SQS - Only allow send messages
    - RequestPath:/000000000000/test_queue # To SQS - Only allow send to this queue

Send Message to SQS

http POST localhost:8000/ \
  AWSRegion='sa-east-1' \
  AWSService='sqs' \
  RequestPath='/000000000000/prod_queue' \
  Action='SendMessage' \
  MessageBody='It Works' \
  MessageAttribute.1.Name='my_attribute_name_1' \
  MessageAttribute.1.Value.StringValue='my_attribute_value_1' \
  MessageAttribute.1.Value.DataType='String' \
  DelaySeconds=45 \
  Version='2012-11-05'

Post Message to Topic

http POST localhost:8000/ \
  AWSRegion='sa-east-1' \
  AWSService='sns' \
  RequestPath='/' \
  Message='{"it": "works"}' \
  Subject='kong message' \
  MessageAttributes.member.1.Name='my_attribute_name_1' \
  MessageAttributes.member.1.Value.StringValue='my_attribute_value_1' \
  MessageAttributes.member.1.Value.DataType='String' \
  Version='2010-03-31' \
  Action='Publish' \
  TopicArn='arn:aws:sns:sa-east-1:000000000000:testtopic'  

Configure plugin - ECR

plugins:
- name: kong-simple-aws-proxy
  config:
    api_prefix: true # Append "api." to target host
    force_content_type_amz_json: true
    override_body:
    - AWSService:ecr
    - AWSRegion:us-east-1
    override_headers:
    - X-Amz-Target:AmazonEC2ContainerRegistry_V20150921.ListImages # Only perform ListImages

List Images

curl -X POST localhost:8000/ \
  -H content-type:application/json \
  -d '{ "RequestPayload": {"repositoryName": "my-repository", "registryId": "000000000000"} }'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published