Skip to content

Instantly share code, notes, and snippets.

View surendrakonna's full-sized avatar

K Surendra Babu surendrakonna

  • Hyderabad
View GitHub Profile
@surendrakonna
surendrakonna / aws-lambda-to-delete-file-from-s3.md
Created November 23, 2020 03:29
AWS lambda function to delete a file from s3 bucket

Create lambda function to delete a file from s3

  1. Create IAM Role with s3 access
  2. Create Lambda function(delete-s3-file) with Ruby 2.7
require 'aws-sdk-s3'
S3_CLIENT = Aws::S3::Client.new

def lambda_handler(event:, context:)
   resp = S3_CLIENT.delete_object({
bucket: event['bucket'], 
@surendrakonna
surendrakonna / docs_controller.rb
Created May 1, 2020 10:51
Fetch API documentation
class Api::DocsController < ApplicationController
def index
@html = Aws::S3::Object.new(ENV['API_DOCS_BUCKET'], ENV['API_DOCS_FILE_NAME']).get.body.string
render html: @html.html_safe, content_type: "text/html"
end
end
@surendrakonna
surendrakonna / config.yml
Created May 1, 2020 10:12
Github actions config
name: API Documentation
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
services:
db:
@surendrakonna
surendrakonna / users_spec.rb
Last active May 1, 2020 09:24
User acceptance test
require 'acceptance_helper'
resource 'Users' do
header "Content-Type", "application/json"
route "/api/users", "Add User" do
parameter :name, "User name", type: :string, example: 'John Wick', required: true
parameter :email, "User email", type: :string, example: 'user@test.com', required: true
parameter :password, "User password", type: :string, required: true
parameter :password_confirmation, type: :string, required: true