Skip to main content

Posts

Showing posts with the label AWS

Some AWS lambda functions

import json from urllib.request import Request, urlopen def lambda_handler(event, context): #webhookurl webhookurl = "https://hooks.slack.com/services/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" # ec2 detail = event['detail'] instance_id = detail['instance-id'] instance_state = detail['state'] messe = "msg here" if instance_id == "i-000d520e3ec8d6f97" : messe = "STG" elif instance_id == "i-0e2b0157636751cc7" : messe = "sest" elif instance_id == "i-018fcaabe46773e38" : messe = "prod" elif instance_id == "i-06fcd00b94795927c" : messe = "live" elif instance_id == "" : messe = "STG02" # (attachmen if instance_state == "stopped": slack_message = { "attachments": [ { ...

Notes on regex sed, bash DOM html, meta tag

Using bash tool sed, awk, grep, vim ... to edit multiple file. Case study DOM tag <html DOCTYPE, meta, charset... https://unix.stackexchange.com/questions/26284/how-can-i-use-sed-to-replace-a-multi-line-string Sed cheatsheet https://gist.github.com/asenchi/2291903 HTML meta tags (recommend way ?) https://www.quackit.com/html_5/tags/html_meta_tag.cfm Example <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml " xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html" charset="EUC-JP" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta name="description" content="content here" ...

AWS Solutions Architect notes

https://aws.amazon.com/certification/certified-solutions-architect-associate/ Link môn thực hành mạng UET  https://uet.vnu.edu.vn/~thanhld/2018s-int3301-1.htm Thực tế có vẻ học theo chương trình kiểu RHCE - Redhat Certified Engineer hay Administrator gì đó. IAM + 101, lab, Billing Alarm, Quiz somehow similar to User/Group management in RHEL Certificate But much more complicated. https://aws.amazon.com/answers/infrastructure-management/crr-monitor/ S3 Glacier and CloudFront S3 version control S3 Cross Region Replication CRR Monitor Storage gateway, Snowball, Transfer Acceleration Section 5 EC2 - The backbone of AWS AMI's - EBS Roto Volumes vs Instance Store Load balancing, load balancer and Health checks CloudWatch EC2 Lamda, Serveless webpage Section 6 Route 53 DNS Section 7 Database Aurora, RedShift, DynamoDB Section 8 VPC NAT Network Access Control Lists vs Security Groups Section 9 Application Services SQS, SWF, SNS, Elastic Transcoder, API Gate...

Rand mm 04

if (intval($http_status / 100) == 4) {             throw new AlgoliaException(isset($answer['message']) ? $answer['message'] : $http_status.' error', $http_status);         } elseif (intval($http_status / 100) != 2) {             throw new \Exception($http_status.': '.$response, $http_status);         } http://www.gobroomecounty.com/files/planning/_pdf/BackyardBurningFactSheet.pdf . GM mv Keep an eye on EFS WP https://blog.lawrencemcdaniel.com/tuning-aws-efs-for-wordpress/ https://en.wikipedia.org/wiki/Furan  => mv to GM mongo restore  https://stackoverflow.com/questions/6770498/how-to-import-bson-file-format-on-mongodb dump https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/ insntall  https://websiteforstudents.com/install-mongodb-on-ubuntu-18-04-lts-beta-server/ noted that guide for ubuntu 16 not work since gpg key o...

Note AWS, cloud 5

php artisan down do what ? put app to maintenance mode. https://medium.com/stashaway-engineering/deploying-a-self-contained-maintenance-page-on-aws-ad4ec8e0a736 heroku have setting for that (cool) https://stackoverflow.com/questions/13693947/how-do-you-put-up-a-maintenance-page-for-aws-when-your-instances-are-behind-an-e May be these thing like this make heroku shine here. WP   can be set maintenance mode too ? pp complain ab WP but sometime it shine. php artisan down not posible in cloud (ie. ELB beanstalk...) => where VPS shine ? http://v2.wp-api.org/extending/adding/#the-controller-pattern https://dba.stackexchange.com/questions/86783/converting-heap-to-myisam-issue https://forums.mysql.com/read.php?22,111012,202235 https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-http-5xx/ https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.html My bg task stop when lock screen. hmm lost few hour of data. https://apple.stack...

Note AWS 3

Multiple profile user CLI Many time we want to use many user/credential with AWS CLI https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html And update ~/.aws/config https://stackoverflow.com/questions/29190202/how-to-change-the-aws-account-using-the-elastic-beanstalk-cli CodePipeline (CodeCommit or CodeBuild) https://medium.com/@xoor/using-aws-codepipeline-to-automate-deployments-to-elasticbeanstalk-e80ca988ef70 git-codecommit https://forums.aws.amazon.com/thread.jspa?threadID=198356 Two questions: 1) Does this command work: $ echo -e "protocol=https\npath=/v1/repos/myrepo\nhost=git-codecommit.us-east-1.amazonaws.com" | aws codecommit credential-helper get 2) If it does not work, could you provide debug logs by running: $ echo -e "protocol=https\npath=/v1/repos/myrepo\nhost=git-codecommit.us-east-1.amazonaws.com" | aws codecommit credential-helper get --debug It is more complicated than it seems. Here is AWS git config https:...

AWS Elasticache Memcached connection

https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/accessing-elasticache.html#access-from-outside-aws http://hourlyapps.blogspot.com/2010/06/examples-of-memcached-commands.html Access memcached https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/GettingStarted.AuthorizeAccess.html Zip include hidden file https://stackoverflow.com/questions/12493206/zip-including-hidden-files phpmemcachedadmin ~ phpMyAdmin or phpPgAdmin ... telnet mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com 11211 stats items stats cachedump 27 100 https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/VPCs.EC.html https://lzone.de/cheat-sheet/memcached VPC ID Security Group ID (sg-...) Cluster: The identifier for the cluster memcached1 Creation Time: The time (UTC) when the cluster was created January 9, 2019 at 11:47:16 AM UTC+7 Configuration Endpoint: The configuration endpoint of the cluster memcached1.ahgofe.cfg.usw1.cache.amazonaws.com:11211 St...