GitHub - Reset and Start Again

📥 How to Reset and Start Again Method 1: Reset your current branch This will discard all local changes and make the local branch exactly match the remote. # First, make sure you're on the right branch git checkout release/v3.1.0 # Fetch the latest changes from remote git fetch origin # Reset your local branch to match the remote version git reset --hard origin/release/v3.1.0 Method 2: Fresh checkout (if you want to start completely fresh) # First, move to a safe location (if you have unsaved work) git stash # Then checkout the release branch, forcing a clean copy git checkout -f release/v3.1.0 # Update to the latest version from remote git pull origin release/v3.1.0 ⚠️ Note: Both methods will discard any uncommitted changes! If you have work you want to keep, commit it to a temporary branch first: ...

June 25, 2025

GitHub - Best Practive Tagging

✅ Daily Git Workflow with Tag Strategy 1. Continue to work on the feature branch git checkout feature/v3.2.0 git pull origin feature/v3.2.0 2. Commit stable changes git add . git commit -m "Fixed export timeout issue" 3. Tag a stable version (optional, when ready) # Use semantic versioning: v3.1.3, v3.1.4, etc. # Tags point to the most recent commit. git tag v3.1.2 4. Push your changes and tag to GitHub git push origin feature/v3.2.0 git push origin v3.1.2 5. Verify your tag (if needed) git tag # List local tags git show v3.1.2 # Show details of the tag git branch --contains v3.1.2 # See which branch includes it Bonus (Optional Advanced Commands) List tags sorted by date (most recent first): ...

June 25, 2025

API Gateway - Configuration

1. Create REST API Go to API Gateway console Create new REST API Create new resource and method Add resource: e.g., “/user-list” Add GET method Integration type: Lambda Function Select your Lambda function Enable CORS if needed Actions → Enable CORS Accept default settings for testing 2. Update “Method request” 3. Update “Integration request” { "limit": "$input.params('limit')" } 4. Deploy and Test Deploy API Note the API endpoint URL ...

June 15, 2025

API Gateway - API Key

In API Gateway: Click on “API Keys” Generate API key for each team member Under API’s Usage Plans: Create new usage plan Add API stage to plan Associate API keys with plan See also: AWS Credentials for CLI AWS STS - Temporary Access Tokens Amazon DynamoDB - Create a Table Amazon DynamoDB - Import CSV Data AWS Lambda - Create a Function AWS Lambda - Grant Access API Gateway - Usage Plan ...

June 15, 2025

API Gateway - Usage Plan

1. Create new usage plan Rate and Burst Rate: Set to 10-20 requests per second for development/testing Recommended: Start with 10 req/sec for controlled testing Burst: Set to 2x your rate (20-40) Recommended: Start with 20 to handle short traffic spikes Quota Settings Quota period: MONTH (most common) Alternative periods: WEEK, DAY Requests per quota period: Start with 50,000/month This allows approximately 1,600 requests per day Can be adjusted based on actual usage patterns Recommended Initial Configuration: ...

June 15, 2025

Amazon DynamoDB - Create a Table

Sign in to AWS Console and navigate to DynamoDB Click “Create table” Table name: e.g., “user_list” Partition key: “user_id (String) Sort key (optional): “first_name” (String) See also: AWS Credentials for CLI AWS STS - Temporary Access Tokens Amazon DynamoDB - Create a Table Amazon DynamoDB - Import CSV Data AWS Lambda - Create a Function AWS Lambda - Grant Access API Gateway - Usage Plan API Gateway - API Key ...

June 15, 2025

AWS STS - Temporary Access Tokens

1. Generate Temporary Credentials First, use the AWS STS (Security Token Service) to generate temporary credentials: # 3600 x 5 = 18000 (5 hours) aws sts get-session-token --duration-seconds 18000 This will return something like: { "Credentials": { "AccessKeyId": "ASIA...", "SecretAccessKey": "...", "SessionToken": "...", "Expiration": "2025-06-13T..." } } 2. Set Environment Variables Then set these environment variables: # Replace the values with your actual credentials from the previous step. export AWS_ACCESS_KEY_ID="your_access_key" export AWS_SECRET_ACCESS_KEY="your_secret_key" export AWS_SESSION_TOKEN="your_session_token" export AWS_DEFAULT_REGION="ap-southeast-2" # Sydney region 3. Verify the environment variables env | grep AWS After setting these variables, try running your Python script again. The credentials will be automatically picked up by the AWS SDK. ...

June 15, 2025

AWS Lambda - Create a Function

Navigate to Lambda in AWS Console Click “Create function” Choose “Author from scratch” Runtime: Python 3.x Name: e.g., “get-user-list” Paste the Python code into “Code” page and click “Deploy” button import boto3 from datetime import datetime from boto3.dynamodb.conditions import Key dynamodb = boto3.resource('dynamodb') table = dynamodb.Table('user_list') def create_nested_structure(data, current_level, max_level): if current_level >= max_level: return data return { f"level_{current_level}": { "data": data, "nested": create_nested_structure(data, current_level + 1, max_level), "metadata": { "level_info": f"This is level {current_level}", "timestamp": datetime.now().isoformat(), "metrics": { "depth": current_level, "remaining_levels": max_level - current_level, "complexity_score": max_level * current_level } } } } def create_complex_response(user_data, nested_level): base_data = { "id": f"user_{user_data['user_id']}", "timestamp": datetime.now().isoformat(), "category": "Personnel", "details": { "name": { "first": user_data['first_name'], "last": user_data['last_name'] }, "company": { "name": user_data['company_name'], "web": user_data['web'] }, "contact_info": { "address": { "street": user_data['address'], "city": user_data['city'], "state": user_data['state'], "postcode": user_data['post'] }, "communication": { "phones": [ { "type": "primary", "number": user_data['phone1'] }, { "type": "secondary", "number": user_data['phone2'] } ], "email": user_data['email'] } } } } return create_nested_structure(base_data, 1, nested_level) def lambda_handler(event, context): try: # Get parameters from event body limit = int(event.get('limit', 10) if event.get('limit') else 10) nested_level = int(event.get('nested_level', 1) if event.get('nested_level') else 1) # Validate nested_level if nested_level < 1: nested_level = 1 elif nested_level > 30: # Set a reasonable maximum nested_level = 30 # 29 nested is the limit on Blue Prism # Scan DynamoDB table with limit response = table.scan( Limit=limit ) items = response.get('Items', []) # Transform items into complex nested structure transformed_data = [create_complex_response(item, nested_level) for item in items] # Create final response return { "statusCode": 200, "headers": { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" }, "success": True, "timestamp": datetime.now().isoformat(), "total_records": len(transformed_data), "limit_applied": limit, "nesting_level": nested_level, "data": transformed_data, "metadata": { "api_version": "1.0", "service": "user-data-api", "complexity_info": { "max_depth": nested_level, "structure_type": "recursive", "total_nodes": len(transformed_data) * nested_level } } } except Exception as e: return { "statusCode": 500, "success": False, "message": "Error processing request", "error": str(e) } ...

June 15, 2025

AWS Credentials for CLI

1. Using AWS CLI Configuration aws configure This will prompt you to enter: AWS Access Key ID AWS Secret Access Key Default region name Default output format 2. Environment Variables export AWS_ACCESS_KEY_ID="your_access_key" export AWS_SECRET_ACCESS_KEY="your_secret_key" export AWS_DEFAULT_REGION="your_region" 3. Credentials File Create or edit ~/.aws/credentials: [default] aws_access_key_id = your_access_key aws_secret_access_key = your_secret_key 4. Clear AWS CLI Configuration (OPTIONAL) To clear your AWS CLI credentials, you have several options: Delete the credentials file: rm ~/.aws/credentials Delete the config file: rm ~/.aws/config Clear specific profile: aws configure --profile your_profile_name and press Enter without entering values # Remove both credentials and config files rm ~/.aws/credentials ~/.aws/config After clearing the credentials, you can reconfigure them using any of the methods described above. ...

June 15, 2025

AWS Lambda - Grant Access

Go to AWS IAM Console Find your Lambda’s role Click on the role name Click “Add permissions” → “Create inline policy” In the JSON editor, paste this policy: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "dynamodb:Scan", "dynamodb:GetItem", "dynamodb:Query" ], "Resource": "arn:aws:dynamodb:ap-southeast-2:6850********:table/user_list" } ] } Click “Review policy” Name it something like “DynamoDBScanPolicy” Click “Create policy” After adding this policy, wait a few seconds and try your Lambda function again. The error should be resolved. ...

June 15, 2025