├── .devcontainer └── devcontainer.json ├── .github └── dependabot.yml ├── .gitignore ├── .gitpod.yml ├── README.md ├── acm └── alb │ ├── deploy │ └── template.yaml ├── api-gateway ├── http │ ├── .aws-sam │ │ ├── build.toml │ │ └── build │ │ │ └── template.yaml │ ├── Readme.md │ ├── bin │ │ ├── build │ │ ├── deploy │ │ └── lint │ └── template.yml └── rest │ ├── .aws-sam │ ├── build.toml │ └── build │ │ └── template.yaml │ ├── bin │ ├── build │ ├── deploy │ └── lint │ └── template.yml ├── api ├── aliases │ ├── Readme.md │ └── alias ├── base64 │ ├── Readme.md │ ├── main.py │ └── main.rb ├── chaining │ └── Readme.md ├── docker │ └── Readme.md ├── filters │ └── Readme.md ├── jp │ └── Readme.md ├── jq │ └── Readme.md ├── localstack │ ├── Readme.md │ ├── requirements.txt │ └── s3.py ├── query │ └── Readme.md ├── skeleton │ ├── Readme.md │ └── skeleton.yaml ├── sts │ ├── Readme.md │ ├── bin │ │ └── deploy │ ├── policy.json │ └── template.yaml ├── wait │ └── Readme.md └── yq │ └── Readme.md ├── appconfig └── feature-flags │ ├── Readme.md │ ├── app │ ├── Gemfile │ ├── Gemfile.lock │ ├── config.ru │ └── main.rb │ ├── deploy │ ├── template.yaml │ └── upload ├── appflow ├── Readme.md └── babylon5_ships.csv ├── apprunner ├── Readme.md └── input.json ├── asg └── basic │ ├── deploy │ └── template.yaml ├── aurora └── basic-cluster │ └── Readme.md ├── aws-asg ├── Readme.md ├── deploy └── template.yaml ├── batch ├── Dockerfile ├── Readme.md └── app │ └── square.py ├── bedrock ├── agent │ └── agent.ipynb ├── fine-tuning │ ├── training-dataset.jsonl │ └── validation-dataset.jsonl ├── prompt-engineering │ ├── chain-of-thought.ipynb │ ├── few-shot.ipynb │ └── zero-shot.ipynb ├── rag │ └── rag-with-haiku.ipynb └── text-generation │ ├── chain-of-thought.ipynb │ ├── code-gen.ipynb │ ├── entity-extraction.ipynb │ ├── few-shot.ipynb │ ├── langchain.ipynb │ ├── llamaindex.ipynb │ ├── qna.ipynb │ ├── sql-gen.ipynb │ ├── summerization.ipynb │ └── zero-shot.ipynb ├── bin ├── aws_cli_install.sh ├── aws_sam_cli_install.sh ├── powershell_cli_install.sh └── terraform_cli_install.sh ├── cfn ├── basic │ ├── template.json │ └── template.yaml ├── cfn-hup │ ├── deploy │ └── template.yaml ├── cfn-init │ ├── deploy │ └── template.yaml ├── creation-policy │ ├── deploy │ └── template.yaml ├── cross-reference-stacks │ ├── bin │ │ ├── deploy_bucket │ │ └── deploy_main │ └── cfn │ │ ├── bucket.yaml │ │ └── template.yaml ├── custom-resource │ └── template.yaml ├── depends │ ├── deploy │ └── template.yaml ├── drift-detection │ ├── deploy │ └── template.yaml ├── import │ ├── deploy │ └── template.yaml ├── intrinsic │ ├── deploy │ └── template.yaml ├── nested-stacks │ ├── Readme.md │ ├── deploy │ ├── s3_bucket.template │ └── template.yaml ├── prevent-stack-update │ ├── Readme.md │ ├── deploy │ └── template.yaml ├── pseudo │ ├── deploy │ └── template.yaml ├── quickstarts │ └── Readme.md ├── skip-delete-resource │ ├── deploy │ ├── hello.txt │ └── template.yaml ├── stack-updates │ ├── deploy │ └── template.yaml └── wait-conditions │ ├── Readme.md │ ├── deploy │ └── template.yaml ├── cloud9 ├── deploy └── template.yaml ├── cloudtrail ├── basic │ ├── 982383527471_CloudTrail_ca-central-1_20240309T2015Z_qpt2VS5TbtFMpzLG.json │ ├── Readme.md │ └── bucket-policy.json └── cloudwatch │ ├── Readme.md │ └── cloud-watch-policy.json ├── cloudwatch └── logs │ ├── agent │ ├── Gemfile │ ├── Gemfile.lock │ ├── Rakefile │ ├── Readme.md │ ├── commands.yaml │ ├── data_generator.rb │ ├── deploy │ ├── export-aws-logs.txt │ ├── packaged-template.yaml │ ├── shogun │ │ ├── .dockerignore │ │ ├── .gitignore │ │ ├── .ruby-version │ │ ├── Dockerfile │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── README.md │ │ ├── Rakefile │ │ ├── app │ │ │ ├── channels │ │ │ │ └── application_cable │ │ │ │ │ ├── channel.rb │ │ │ │ │ └── connection.rb │ │ │ ├── controllers │ │ │ │ ├── application_controller.rb │ │ │ │ └── concerns │ │ │ │ │ └── .keep │ │ │ ├── jobs │ │ │ │ └── application_job.rb │ │ │ ├── mailers │ │ │ │ └── application_mailer.rb │ │ │ ├── models │ │ │ │ ├── application_record.rb │ │ │ │ └── concerns │ │ │ │ │ └── .keep │ │ │ └── views │ │ │ │ └── layouts │ │ │ │ ├── mailer.html.erb │ │ │ │ └── mailer.text.erb │ │ ├── aws │ │ │ └── amazon-cloudwatch-agent.json │ │ ├── bin │ │ │ ├── bundle │ │ │ ├── docker-entrypoint │ │ │ ├── rails │ │ │ ├── rake │ │ │ └── setup │ │ ├── config.ru │ │ ├── config │ │ │ ├── application.rb │ │ │ ├── boot.rb │ │ │ ├── cable.yml │ │ │ ├── credentials.yml.enc │ │ │ ├── database.yml │ │ │ ├── environment.rb │ │ │ ├── environments │ │ │ │ ├── development.rb │ │ │ │ ├── production.rb │ │ │ │ └── test.rb │ │ │ ├── initializers │ │ │ │ ├── cors.rb │ │ │ │ ├── filter_parameter_logging.rb │ │ │ │ └── inflections.rb │ │ │ ├── locales │ │ │ │ └── en.yml │ │ │ ├── puma.rb │ │ │ ├── routes.rb │ │ │ └── storage.yml │ │ ├── db │ │ │ └── seeds.rb │ │ ├── lib │ │ │ └── tasks │ │ │ │ └── .keep │ │ ├── log │ │ │ └── .keep │ │ ├── public │ │ │ └── robots.txt │ │ ├── storage │ │ │ └── .keep │ │ ├── test │ │ │ ├── channels │ │ │ │ └── application_cable │ │ │ │ │ └── connection_test.rb │ │ │ ├── controllers │ │ │ │ └── .keep │ │ │ ├── fixtures │ │ │ │ └── files │ │ │ │ │ └── .keep │ │ │ ├── integration │ │ │ │ └── .keep │ │ │ ├── mailers │ │ │ │ └── .keep │ │ │ ├── models │ │ │ │ └── .keep │ │ │ └── test_helper.rb │ │ ├── tmp │ │ │ └── .keep │ │ └── vendor │ │ │ └── .keep │ ├── template.yaml │ └── upload │ ├── basic │ ├── Gemfile │ ├── Gemfile.lock │ ├── Rakefile │ ├── Readme.md │ ├── generate_logs.py │ ├── put-logs │ ├── put_logs.rb │ └── web_server_logs.log │ └── events │ ├── Gemfile │ ├── Gemfile.lock │ ├── Rakefile │ ├── Readme.md │ ├── generate_json_logs.py │ ├── json │ ├── put_logs_json.rb │ └── web_server_logs.json ├── codepipeline └── v1 │ ├── app │ ├── .gitignore │ ├── package-lock.json │ ├── package.json │ ├── public │ │ └── index.html │ └── src │ │ └── app.js │ ├── aws │ ├── cfn │ │ └── template.yaml │ ├── codebuild │ │ └── buildspec.yml │ └── codedeploy │ │ ├── appspec.yml │ │ └── scripts │ │ ├── after_install.sh │ │ ├── before_install.sh │ │ ├── start_application.sh │ │ └── stop_application.sh │ └── bin │ └── deploy ├── codewhisper ├── Gemfile ├── Gemfile.lock ├── game.rb └── main.rb ├── copilot-cli └── Readme.md ├── datasync ├── Readme.md └── hello.txt ├── device-farm ├── Gemfile ├── Gemfile.lock ├── HelloWorld.apk ├── MainActivity.kt ├── Readme.md └── main.rb ├── dms └── serverless │ ├── Readme.md │ ├── bin │ ├── deploy_mysql │ └── deploy_postgres │ ├── cfn │ ├── mysql.yaml │ └── postgres.yaml │ ├── data.sql │ ├── mysql.sql │ └── postgres.sql ├── documentdb ├── Gemfile ├── Gemfile.lock ├── Readme.md └── main.rb ├── dynamodb ├── basic │ ├── bin │ │ └── deploy │ └── template.yaml └── simple │ ├── .aws-sam │ ├── build.toml │ └── build │ │ └── template.yaml │ ├── bin │ ├── build │ ├── deploy │ └── put │ ├── item.json │ └── template.yml ├── eb ├── advanced │ ├── .gitignore │ ├── Readme.md │ ├── app │ │ ├── .elasticbeanstalk │ │ │ └── config.yml │ │ ├── .gitignore │ │ ├── app.js │ │ ├── index.html │ │ ├── index.js │ │ ├── package-lock.json │ │ ├── package.json │ │ └── style.css │ ├── docker-compose.yml │ ├── rds │ │ ├── deploy │ │ └── template.yaml │ └── sql │ │ ├── schema.sql │ │ └── seed.sql └── basic │ ├── Readme.md │ ├── docker-compose.yml │ └── example │ ├── .dockerignore │ ├── .ebextensions │ └── init.config │ ├── .gitignore │ ├── .ruby-version │ ├── Dockerfile │ ├── Gemfile │ ├── Gemfile.lock │ ├── README.md │ ├── Rakefile │ ├── app │ ├── assets │ │ ├── images │ │ │ └── .keep │ │ └── stylesheets │ │ │ └── application.css │ ├── channels │ │ └── application_cable │ │ │ ├── channel.rb │ │ │ └── connection.rb │ ├── controllers │ │ ├── application_controller.rb │ │ └── concerns │ │ │ └── .keep │ ├── helpers │ │ └── application_helper.rb │ ├── jobs │ │ └── application_job.rb │ ├── mailers │ │ └── application_mailer.rb │ ├── models │ │ ├── application_record.rb │ │ ├── concerns │ │ │ └── .keep │ │ └── thing.rb │ └── views │ │ ├── application │ │ └── home.html.erb │ │ └── layouts │ │ ├── application.html.erb │ │ ├── mailer.html.erb │ │ └── mailer.text.erb │ ├── bin │ ├── bundle │ ├── docker-entrypoint │ ├── rails │ ├── rake │ └── setup │ ├── config.ru │ ├── config │ ├── application.rb │ ├── boot.rb │ ├── cable.yml │ ├── credentials.yml.enc │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── content_security_policy.rb │ │ ├── filter_parameter_logging.rb │ │ ├── inflections.rb │ │ └── permissions_policy.rb │ ├── locales │ │ └── en.yml │ ├── puma.rb │ ├── routes.rb │ └── storage.yml │ ├── db │ ├── migrate │ │ └── 20240304193005_create_tables.rb │ ├── schema.rb │ └── seeds.rb │ ├── lib │ ├── assets │ │ └── .keep │ └── tasks │ │ └── .keep │ ├── log │ └── .keep │ ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── apple-touch-icon-precomposed.png │ ├── apple-touch-icon.png │ ├── favicon.ico │ └── robots.txt │ ├── storage │ └── .keep │ ├── tmp │ ├── .keep │ ├── pids │ │ └── .keep │ └── storage │ │ └── .keep │ └── vendor │ └── .keep ├── ebs ├── basic │ ├── Readme.md │ ├── deploy │ └── template.yaml ├── encrypt │ ├── Readme.md │ ├── deploy │ └── template.yaml ├── multi-atttach │ ├── Readme.md │ ├── deploy │ └── template.yaml └── resize │ ├── Readme.md │ ├── deploy │ └── template.yaml ├── ec2 └── userdata │ ├── userdata.ps1 │ ├── userdata.sh │ └── userdata.yml ├── ecr ├── Readme.md └── app │ ├── Dockerfile │ ├── Readme.md │ ├── app.py │ └── requirements.txt ├── ecs ├── ec2 │ ├── Readme.md │ ├── capacity-provider.yaml │ ├── deploy │ ├── deploy-capacity-provider │ ├── policies │ │ ├── execution.json │ │ └── task.json │ ├── serv.json │ ├── task-def.json │ └── template.yaml ├── fargate │ ├── Readme.md │ ├── deploy │ ├── serv.json │ ├── session-manager-plugin.deb │ ├── task-def.json │ └── template.yaml └── service-connect │ ├── Readme.md │ ├── deploy │ ├── serv1.json │ ├── serv2.json │ └── template.yaml ├── efs └── basic │ ├── Readme.md │ ├── deploy │ └── template.yaml ├── eks ├── Readme.md ├── iam_policy.json └── node-role-trust-relationship.json ├── elastic-transcoder ├── App2Container.mp4 ├── Readme.md ├── content-config.json ├── inputs.json ├── outputs.json ├── thumbnail-config.json └── user-metadata.json ├── elasticache └── serverless │ ├── Readme.md │ ├── deploy │ ├── docker-compose.yml │ └── template.yaml ├── elb └── alb │ ├── deploy │ └── template.yaml ├── fsx └── openzfs │ └── Readme.md ├── global-accelerator ├── deploy └── template.yaml ├── glue └── data-catalog │ ├── .gitignore │ ├── Readme.md │ ├── data │ └── .keep │ └── json │ ├── policy.json │ └── trust-policy.json ├── iam ├── policy │ ├── Readme.md │ ├── policy.yml │ └── update └── type-of-policies │ └── template.yml ├── kafka ├── Gemfile ├── Gemfile.lock ├── Readme.md ├── app │ └── consumers │ │ ├── application_consumer.rb │ │ └── example_consumer.rb ├── karafka.rb └── log │ └── development.log ├── kendra ├── Readme.md ├── data-source-policy.json ├── index-policy.json ├── oliver-twist.pdf └── split │ ├── oliver-twist_Part1.pdf │ ├── oliver-twist_Part10.pdf │ ├── oliver-twist_Part11.pdf │ ├── oliver-twist_Part12.pdf │ ├── oliver-twist_Part13.pdf │ ├── oliver-twist_Part14.pdf │ ├── oliver-twist_Part15.pdf │ ├── oliver-twist_Part16.pdf │ ├── oliver-twist_Part17.pdf │ ├── oliver-twist_Part18.pdf │ ├── oliver-twist_Part19.pdf │ ├── oliver-twist_Part2.pdf │ ├── oliver-twist_Part20.pdf │ ├── oliver-twist_Part21.pdf │ ├── oliver-twist_Part22.pdf │ ├── oliver-twist_Part23.pdf │ ├── oliver-twist_Part24.pdf │ ├── oliver-twist_Part25.pdf │ ├── oliver-twist_Part26.pdf │ ├── oliver-twist_Part27.pdf │ ├── oliver-twist_Part28.pdf │ ├── oliver-twist_Part29.pdf │ ├── oliver-twist_Part3.pdf │ ├── oliver-twist_Part30.pdf │ ├── oliver-twist_Part31.pdf │ ├── oliver-twist_Part32.pdf │ ├── oliver-twist_Part33.pdf │ ├── oliver-twist_Part34.pdf │ ├── oliver-twist_Part35.pdf │ ├── oliver-twist_Part36.pdf │ ├── oliver-twist_Part37.pdf │ ├── oliver-twist_Part38.pdf │ ├── oliver-twist_Part4.pdf │ ├── oliver-twist_Part5.pdf │ ├── oliver-twist_Part6.pdf │ ├── oliver-twist_Part7.pdf │ ├── oliver-twist_Part8.pdf │ └── oliver-twist_Part9.pdf ├── kinesis ├── datastreams │ ├── Readme.md │ ├── deploy │ ├── kpl-example │ │ ├── pom.xml │ │ ├── src │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── co │ │ │ │ │ └── exampro │ │ │ │ │ └── App.java │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── co │ │ │ │ └── exampro │ │ │ │ └── AppTest.java │ │ └── target │ │ │ ├── classes │ │ │ └── co │ │ │ │ └── exampro │ │ │ │ └── App.class │ │ │ └── test-classes │ │ │ └── co │ │ │ └── exampro │ │ │ └── AppTest.class │ └── template.yaml └── firehose │ ├── Gemfile │ ├── Gemfile.lock │ ├── deploy │ ├── record.rb │ └── template.yaml ├── lambda ├── container │ ├── .aws-sam │ │ ├── build.toml │ │ └── build │ │ │ ├── packaged.yaml │ │ │ └── template.yaml │ ├── Dockerfile │ ├── bin │ │ ├── bootstrap │ │ ├── build │ │ ├── deploy │ │ ├── lint │ │ └── package │ ├── function │ │ ├── function.py │ │ └── requirements.txt │ ├── samconfig.toml │ └── template.yml ├── inline │ ├── .aws-sam │ │ ├── build.toml │ │ └── build │ │ │ └── template.yaml │ ├── Readme.md │ ├── bin │ │ ├── build │ │ ├── deploy │ │ └── lint │ └── template.yml ├── layers │ ├── .aws-sam │ │ ├── build.toml │ │ └── build │ │ │ ├── InlineLambda │ │ │ └── function.py │ │ │ ├── packaged.yaml │ │ │ └── template.yaml │ ├── .gitignore │ ├── bin │ │ ├── build │ │ ├── deploy │ │ ├── layer │ │ ├── lint │ │ └── package │ ├── function │ │ └── function.py │ ├── samconfig.toml │ └── template.yml ├── rust │ ├── Readme.md │ └── example │ │ ├── .gitignore │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs ├── zip_local │ ├── .aws-sam │ │ ├── build.toml │ │ └── build │ │ │ ├── InlineLambda │ │ │ └── function.py │ │ │ └── template.yaml │ ├── bin │ │ ├── build │ │ ├── deploy │ │ └── lint │ ├── function │ │ └── function.py │ ├── samconfig.toml │ └── template.yml └── zip_package │ ├── .aws-sam │ ├── build.toml │ └── build │ │ ├── InlineLambda │ │ └── function.py │ │ ├── packaged.yaml │ │ └── template.yaml │ ├── bin │ ├── build │ ├── deploy │ ├── lint │ └── package │ ├── function │ └── function.py │ ├── samconfig.toml │ └── template.yml ├── memorydb ├── Readme.md ├── deploy └── template.yaml ├── mq ├── amqp │ ├── Gemfile │ ├── Gemfile.lock │ ├── consumer.rb │ └── publisher.rb ├── mqtt │ ├── Gemfile │ ├── Gemfile.lock │ ├── consumer.rb │ └── publisher.rb └── stomp │ ├── Gemfile │ ├── Gemfile.lock │ ├── consumer.rb │ └── publisher.rb ├── opensearch └── opensearch │ ├── Gemfile │ ├── Gemfile.lock │ ├── Readme.md │ └── main.rb ├── personalize ├── item_data.csv ├── main.py ├── requirements.txt ├── user_data.csv └── user_interaction_data.csv ├── polly ├── Gemfile ├── Gemfile.lock └── main.rb ├── rds ├── basic │ ├── Readme.md │ ├── deploy │ └── template.yaml └── pgvector │ └── Readme.md ├── rekognition ├── Gemfile ├── Gemfile.lock ├── Readme.md ├── andrew.jpg └── main.rb ├── route53 ├── alias │ ├── deploy │ └── template.yaml └── basic │ ├── Readme.md │ ├── deploy │ └── template.yaml ├── s3 ├── acls │ ├── Readme.md │ ├── policy.json │ └── policy.xml ├── bash-scripts │ ├── create-bucket │ ├── delete-bucket │ ├── delete-objects │ ├── get-newest-bucket │ ├── list-buckets │ ├── list-objects │ ├── put-object │ └── sync ├── batch-operations │ ├── .gitignore │ ├── Readme.md │ ├── bin │ │ └── create_files │ └── files │ │ ├── .keep │ │ └── manifest.csv ├── bucket-policy │ ├── Readme.md │ └── policy.json ├── byte-range │ ├── Readme.md │ ├── hello.txt │ └── range.txt ├── change-storage-class │ ├── Readme.md │ └── hello.txt ├── checksums │ ├── Readme.md │ ├── myfile.txt │ └── sha1_checksum.rb ├── cors │ ├── Readme.md │ ├── bucket-policy.json │ ├── bucket-policy2.json │ ├── cors.json │ ├── hello.js │ ├── index.html │ └── website.json ├── dual-endpoints │ ├── Readme.md │ ├── dualstack.txt │ └── standard.txt ├── encryption-client │ ├── Gemfile │ ├── Gemfile.lock │ ├── Readme.md │ └── encrypt.rb ├── encryption │ ├── Readme.md │ ├── hello.txt │ └── ssec.key ├── etags │ ├── .terraform.lock.hcl │ ├── main.tf │ └── myfile.txt ├── event-notifications │ ├── .gitignore │ ├── .terraform.lock.hcl │ ├── bin │ │ ├── function │ │ ├── queue │ │ ├── test_server │ │ └── topic │ ├── bucket.tf │ ├── code │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── queue.rb │ │ └── topic.rb │ ├── function │ │ └── function.py │ ├── lambda.tf │ ├── main.tf │ ├── queue.tf │ └── topic.tf ├── glacier │ ├── Readme.md │ └── hello.txt ├── iac │ ├── cdk │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── README.md │ │ ├── bin │ │ │ └── cdk.ts │ │ ├── cdk.json │ │ ├── jest.config.js │ │ ├── lib │ │ │ └── cdk-stack.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── test │ │ │ └── cdk.test.ts │ │ └── tsconfig.json │ ├── cfn │ │ ├── delete-stack │ │ ├── deploy │ │ └── template.yaml │ └── terraform │ │ ├── .terraform.lock.hcl │ │ ├── main.tf │ │ └── s3.tf ├── lifecycle │ ├── Readme.md │ └── lifecycle.json ├── metadata │ ├── Readme.md │ └── hello.txt ├── multipart-upload │ ├── .gitignore │ ├── Readme.md │ └── parts.json ├── object-locks │ ├── Readme.md │ ├── compliance.txt │ ├── default.json │ ├── gov.txt │ └── legal.txt ├── object-tags │ ├── Readme.md │ └── hello.txt ├── powershell-scripts │ └── s3.ps1 ├── prefixes │ ├── Readme.md │ └── hello.txt ├── replication │ ├── Readme.md │ ├── hello.txt │ ├── policy.json │ ├── replication.json │ └── trust.json ├── s3-select │ ├── Gemfile │ ├── Gemfile.lock │ ├── Readme.md │ ├── select.rb │ └── top_20_animes.csv ├── s3-versioning │ └── s3-versioning-commands.sh ├── sdk │ ├── java │ │ ├── Readme.md │ │ └── myapp │ │ │ ├── README.md │ │ │ ├── pom.xml │ │ │ ├── src │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── myapp │ │ │ │ │ ├── App.java │ │ │ │ │ └── DependencyFactory.java │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── myapp │ │ │ │ └── AppTest.java │ │ │ ├── target │ │ │ ├── classes │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── myapp │ │ │ │ │ ├── App.class │ │ │ │ │ └── DependencyFactory.class │ │ │ └── test-classes │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── myapp │ │ │ │ └── AppTest.class │ │ │ └── template.yaml │ └── ruby │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── resp │ │ └── s3.rb ├── server-logs │ ├── .gitignore │ ├── Readme.md │ ├── hello.txt │ ├── hello_mars.txt │ ├── hello_moon.txt │ ├── logging.json │ └── policy.json └── static-website-hosting │ ├── Readmd.md │ ├── app │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ └── src │ │ ├── AboutPage.js │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── ContactPage.js │ │ ├── HomePage.js │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ ├── reportWebVitals.js │ │ └── setupTests.js │ ├── bin │ ├── deploy │ └── sync │ └── template.yaml ├── sage-maker └── nlp-metrics │ └── nlp-metrics.ipynb ├── secrets-manager ├── basic │ ├── Gemfile │ ├── Gemfile.lock │ ├── Readme.md │ ├── deploy │ ├── main.rb │ └── template.yaml ├── db │ ├── deploy │ └── template.yaml └── mask │ ├── deploy │ └── template.yaml ├── sns └── basic │ ├── .aws-sam │ ├── build.toml │ └── build │ │ └── template.yaml │ ├── bin │ ├── build │ ├── deploy │ └── publish │ └── template.yml ├── sqs ├── fifo │ ├── bin │ │ ├── deploy │ │ ├── recieve │ │ └── send │ ├── send-message.json │ └── template.yaml └── standard │ ├── bin │ ├── deploy │ ├── recieve │ └── send │ ├── ruby │ ├── Gemfile │ ├── Gemfile.lock │ ├── recieve.rb │ └── send.rb │ ├── send-message.json │ └── template.yaml ├── step-functions ├── hello │ ├── hello-world.json │ └── hello-world.yml └── star-trek │ ├── Readme.md │ ├── dukat.jpg │ ├── event-pattern.json │ ├── flow.yml │ └── picard.jpg ├── textract ├── Gemfile ├── Gemfile.lock ├── Readme.md ├── main.rb └── tax-doc.png ├── translate ├── Gemfile ├── Gemfile.lock └── main.rb └── vpc ├── basics ├── create_vpc └── delete_vpc ├── eigw ├── template-ipv4.yml └── template-ipv6.yml ├── gateway-endpoint └── lambda.rb ├── inteface-endpoint └── template.yml ├── nacl ├── Readme.md └── template.yml ├── nat-gateway └── template.yml ├── peering-connection ├── template-a.yml └── template-b.yml └── sg ├── Readme.md └── template.yml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for more information: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | # https://containers.dev/guide/dependabot 6 | 7 | version: 2 8 | updates: 9 | - package-ecosystem: "devcontainers" 10 | directory: "/" 11 | schedule: 12 | interval: weekly 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # .tfstate files 5 | *.tfstate 6 | *.tfstate.* 7 | 8 | # Crash log files 9 | crash.log 10 | crash.*.log 11 | 12 | # Exclude all .tfvars files, which are likely to contain sensitive data, such as 13 | # password, private keys, and other secrets. These should not be part of version 14 | # control as they are data points which are potentially sensitive and subject 15 | # to change depending on the environment. 16 | *.tfvars 17 | *.tfvars.json 18 | 19 | # Ignore override files as they are usually used to override resources locally and so 20 | # are not -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS-Examples 2 | A codebase of all the AWS examples used through AWS Certification Study Courses. 3 | 4 | > StakPak is allowed to RAG and use this repo to generate out IaC 5 | -------------------------------------------------------------------------------- /acm/alb/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy asg acm" 4 | 5 | STACK_NAME="alb-basic-acm" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /api-gateway/http/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions] 4 | 5 | [layer_build_definitions] 6 | -------------------------------------------------------------------------------- /api-gateway/http/Readme.md: -------------------------------------------------------------------------------- 1 | curl https://xxiqb2lmaf.execute-api.ca-central-1.amazonaws.com?first_name=Andrew&last_name=Brown -------------------------------------------------------------------------------- /api-gateway/http/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # we need the absolute path because relative path was giving us trouble 5 | root_path=$(realpath .) 6 | 7 | # cfn-lint 8 | # ------------------- 9 | # This will check our cloudformation template to ensure its valid format 10 | echo "== CFN linting..." 11 | cfn-lint "${root_path}/template.yml" -------------------------------------------------------------------------------- /api-gateway/rest/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions] 4 | 5 | [layer_build_definitions] 6 | -------------------------------------------------------------------------------- /api-gateway/rest/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # we need the absolute path because relative path was giving us trouble 5 | root_path=$(realpath .) 6 | 7 | # cfn-lint 8 | # ------------------- 9 | # This will check our cloudformation template to ensure its valid format 10 | echo "== CFN linting..." 11 | cfn-lint "${root_path}/template.yml" -------------------------------------------------------------------------------- /api/aliases/Readme.md: -------------------------------------------------------------------------------- 1 | # copy our alias file 2 | 3 | copy our file 4 | ```sh 5 | cp /workspace/AWS-Examples/api/aliases/alias ~/.aws/cli/alias 6 | ``` 7 | 8 | make sure it exists 9 | 10 | ```sh 11 | cat ~/.aws/cli/alias 12 | ``` -------------------------------------------------------------------------------- /api/aliases/alias: -------------------------------------------------------------------------------- 1 | [toplevel] 2 | dsub = ec2 describe-subnets --filters Name=state,Values=available --query Subnets[].SubnetId --output table -------------------------------------------------------------------------------- /api/base64/Readme.md: -------------------------------------------------------------------------------- 1 | echo 'Send reinforcements' | base64 2 | 3 | echo "U2VuZCByZWluZm9yY2VtZW50cw==" | base64 -d -------------------------------------------------------------------------------- /api/base64/main.py: -------------------------------------------------------------------------------- 1 | import base64 2 | encoded = base64.b64encode(b'Send reinforcements') 3 | print(encoded) 4 | data = base64.b64decode(encoded) 5 | print(data) -------------------------------------------------------------------------------- /api/base64/main.rb: -------------------------------------------------------------------------------- 1 | require "base64" 2 | 3 | text = 'Send reinforcements' 4 | 5 | enc = Base64.encode64(text) 6 | puts "encoded" 7 | puts enc 8 | plain = Base64.decode64(enc) 9 | puts "decoded" 10 | puts plain 11 | -------------------------------------------------------------------------------- /api/docker/Readme.md: -------------------------------------------------------------------------------- 1 | ## Install docker container and show us the version 2 | 3 | docker run --rm -it amazon/aws-cli --version 4 | 5 | ## Attempt to list our s3 buckets 6 | 7 | docker run --rm -it amazon/aws-cli s3 ls 8 | 9 | ## Connect with credentials 10 | 11 | docker run --rm -it \ 12 | -v ~/.aws:/root/.aws \ 13 | public.ecr.aws/aws-cli/aws-cli \ 14 | s3 ls -------------------------------------------------------------------------------- /api/filters/Readme.md: -------------------------------------------------------------------------------- 1 | # Get a bunch of subnets 2 | 3 | aws ec2 describe-subnets --region us-east-1 --query Subnets[].AvailabilityZone 4 | 5 | aws ec2 describe-subnets --region us-east-1 --filter Name=availability-zone,Values=us-east-1b,us-east-1a --query Subnets[].AvailabilityZone -------------------------------------------------------------------------------- /api/jp/Readme.md: -------------------------------------------------------------------------------- 1 | aws ec2 describe-vpcs | jp # this will return in an error 2 | aws ec2 describe-vpcs | jp Vpcs # we need to select something 3 | aws ec2 describe-vpcs | jp "Vpcs[?IsDefault == false]" 4 | aws ec2 describe-vpcs | jp "Vpcs[*].CidrBlock 5 | 6 | aws ec2 describe-vpcs | jp "Vpcs[*].CidrBlock | {Blocks: join(',',@) } " 7 | aws ec2 describe-vpcs --query "Vpcs[*].CidrBlock | { Blocks: join(',',@) }" -------------------------------------------------------------------------------- /api/localstack/Readme.md: -------------------------------------------------------------------------------- 1 | ## Instal LocalStack CLI 2 | 3 | 4 | ```sh 5 | docker network create localstack 6 | brew install localstack/tap/localstack-cli 7 | localstack start 8 | ``` 9 | 10 | ``` 11 | aws s3 ls --endpoint-url https://0.0.0.0:4566 12 | ``` 13 | 14 | ## Lets create some mock s3 buckets 15 | 16 | ```sh 17 | aws s3 mb s3://amazon.com --endpoint-url http://0.0.0.0:4566 18 | ``` 19 | 20 | ## Set an Env Var endpoint just for S3 21 | 22 | export AWS_ENDPOINT_URL_S3="http://0.0.0.0:4566" -------------------------------------------------------------------------------- /api/localstack/requirements.txt: -------------------------------------------------------------------------------- 1 | boto3 -------------------------------------------------------------------------------- /api/localstack/s3.py: -------------------------------------------------------------------------------- 1 | import boto3 2 | 3 | # Configure AWS credentials 4 | # Assuming they are set in environment variables or AWS credentials file 5 | 6 | # Create an S3 client with a custom endpoint 7 | s3_client = boto3.client( 8 | 's3', 9 | region_name='us-east-1', 10 | endpoint_url='http://0.0.0.0:4566' 11 | ) 12 | s3_client.create_bucket(Bucket='google.com') -------------------------------------------------------------------------------- /api/query/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | ec2 describe-vpcs --query Vpcs[].[CidrBlocck,VpcId] 3 | 4 | aws ec2 describe-vpcs --query 'Vpcs[].{cidr: CidrBlock, vpcid: VpcId}' --output json -------------------------------------------------------------------------------- /api/skeleton/Readme.md: -------------------------------------------------------------------------------- 1 | ## Generate our skeleton for EC2 2 | 3 | --image-id ami-079db87dc4c10ac91 \ 4 | --instance-type t2.micro \ 5 | --region us-east-1 \ 6 | 7 | aws ec2 run-instances --generate-cli-skeleton > skeleton.json 8 | 9 | ## Convert Json to YAML 10 | 11 | yq -oy -p=json skeleton.json > skeleton.yaml 12 | 13 | ## Load Yaml input file 14 | 15 | aws ec2 run-instances --cli-input-yaml file://skeleton.yaml --region us-east-1 -------------------------------------------------------------------------------- /api/skeleton/skeleton.yaml: -------------------------------------------------------------------------------- 1 | ImageId: "ami-079db87dc4c10ac91" 2 | InstanceType: t2.micro -------------------------------------------------------------------------------- /api/sts/bin/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | aws cloudformation deploy \ 4 | --template-file template.yaml \ 5 | --stack-name my-sts-fun-stack \ 6 | --capabilities CAPABILITY_IAM -------------------------------------------------------------------------------- /api/sts/policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [{ 4 | "Effect": "Allow", 5 | "Action": "sts:AssumeRole", 6 | "Resource": "arn:aws:iam::982383527471:role/my-sts-fun-stack-StsRole-UBQlCIzagA7n" 7 | }] 8 | } -------------------------------------------------------------------------------- /api/wait/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create an EC2 instance 2 | 3 | INSTANCE_ID=$(aws ec2 run-instances \ 4 | --image-id "ami-079db87dc4c10ac91" \ 5 | --instance-type t2.micro \ 6 | --region us-east-1 \ 7 | --query Instances[].InstanceId \ 8 | --output text) 9 | 10 | ## To watch for EC2 instance to be ready 11 | 12 | aws ec2 wait instance-status-ok --instance-ids $INSTANCE_ID --region us-east-1 -------------------------------------------------------------------------------- /api/yq/Readme.md: -------------------------------------------------------------------------------- 1 | brew install yq 2 | 3 | aws ec2 describe-vpcs | yq . -pjson -oy 4 | aws ec2 describe-vpcs | yq ".Vpcs[].CidrBlock" -pjson -oy 5 | -------------------------------------------------------------------------------- /appconfig/feature-flags/app/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "sinatra" # web app 6 | gem 'pry' # debugger 7 | gem 'nokogiri' # xml parsing 8 | gem 'aws-sdk-appconfigdata' 9 | gem 'rackup' -------------------------------------------------------------------------------- /appconfig/feature-flags/app/config.ru: -------------------------------------------------------------------------------- 1 | # config.ru (run with rackup) 2 | require './main' 3 | run MyApp -------------------------------------------------------------------------------- /appconfig/feature-flags/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2 instance" 4 | 5 | STACK_NAME="aws-appconfig-feature-flags" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region us-east-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /appconfig/feature-flags/upload: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | MYPATH=/workspace/AWS-Examples/appconfig/feature-flags 3 | 4 | rm $MYPATH/app.zip 5 | zip -r app.zip $MYPATH/app 6 | aws s3 rm s3://my-appconfig-example-234324/app.zip --region us-east-1 7 | aws s3 cp $MYPATH/app.zip s3://my-appconfig-example-234324 --region us-east-1 -------------------------------------------------------------------------------- /apprunner/Readme.md: -------------------------------------------------------------------------------- 1 | ```sh 2 | aws apprunner create-service --cli-input-json file://input.json --region us-east-1 3 | ``` -------------------------------------------------------------------------------- /apprunner/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "ServiceName": "app-python", 3 | "SourceConfiguration": { 4 | "AuthenticationConfiguration": { 5 | "AccessRoleArn": "arn:aws:iam::982383527471:role/service-role/AppRunnerECRAccessRole" 6 | }, 7 | "ImageRepository": { 8 | "ImageIdentifier": "982383527471.dkr.ecr.us-east-1.amazonaws.com/app:latest", 9 | "ImageConfiguration": { 10 | "Port": "4567" 11 | }, 12 | "ImageRepositoryType": "ECR" 13 | } 14 | }, 15 | "InstanceConfiguration": { 16 | "Cpu": "0.25 vCPU", 17 | "Memory": "1 GB" 18 | } 19 | } -------------------------------------------------------------------------------- /asg/basic/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy asg" 4 | 5 | STACK_NAME="asg-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /aws-asg/Readme.md: -------------------------------------------------------------------------------- 1 | AWS ASG does not automatically turn resources into scalable resources. 2 | 3 | CFN template is useless here, -------------------------------------------------------------------------------- /aws-asg/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2" 4 | 5 | STACK_NAME="aws-asg-ec2-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /batch/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8 2 | 3 | # Set the working directory 4 | WORKDIR /app 5 | 6 | # Copy the Python script into the container 7 | COPY app/square.py /app 8 | 9 | ENV PYTHONUNBUFFERED=1 10 | 11 | # Run the Python script when the container starts 12 | CMD ["python", "-u", "square.py", "3"] -------------------------------------------------------------------------------- /batch/app/square.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def square(x): 4 | return x * x 5 | 6 | if __name__ == "__main__": 7 | if len(sys.argv) != 2: 8 | print("Usage: square.py ") 9 | sys.exit(1) 10 | 11 | num = int(sys.argv[1]) 12 | result = square(num) 13 | print(f"The square of {num} is {result}") -------------------------------------------------------------------------------- /bin/aws_cli_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | cd /workspace 3 | curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" 4 | unzip awscliv2.zip 5 | sudo ./aws/install 6 | cd $THEIA_WORKSPACE_ROOT -------------------------------------------------------------------------------- /bin/aws_sam_cli_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | cd /workspace 3 | curl -L "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip" -o "samcli.zip" 4 | unzip samcli.zip -d sam-installation 5 | sudo ./sam-installation/install 6 | cd $THEIA_WORKSPACE_ROOT -------------------------------------------------------------------------------- /bin/powershell_cli_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | sudo apt-get update 3 | sudo apt-get install -y wget apt-transport-https software-properties-common 4 | source /etc/os-release 5 | wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb 6 | sudo dpkg -i packages-microsoft-prod.deb 7 | rm packages-microsoft-prod.deb 8 | sudo apt-get update 9 | sudo apt-get install -y powershell 10 | # pwsh 11 | # Install-Module -Name AWS.Tools.Installer -------------------------------------------------------------------------------- /bin/terraform_cli_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | sudo apt-get update && sudo apt-get install -y gnupg software-properties-common 3 | wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg 4 | gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint 5 | echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list 6 | sudo apt update 7 | sudo apt-get install terraform -------------------------------------------------------------------------------- /cfn/basic/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion": "2010-09-09", 3 | "Description": "Json Example with sample bucket", 4 | "Parameters": { 5 | "BucketName": { 6 | "Type": "String", 7 | "Default": "json-example-cfn-325252" 8 | } 9 | }, 10 | "Resources": { 11 | "S3Bucket": { 12 | "Type": "AWS::S3::Bucket", 13 | "Properties": { 14 | "BucketName": { 15 | "Ref": "BucketName" 16 | } 17 | } 18 | } 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /cfn/basic/template.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Description: Json Example with sample bucket 4 | Parameters: 5 | BucketName: 6 | Type: String 7 | Default: json-example-cfn-325252 8 | Resources: 9 | S3Bucket: 10 | Type: AWS::S3::Bucket 11 | Properties: 12 | BucketName: 13 | Ref: BucketName -------------------------------------------------------------------------------- /cfn/cfn-hup/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="cfn-hup" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/cfn-init/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="cfn-init" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/creation-policy/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="creation-policy" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/cross-reference-stacks/bin/deploy_bucket: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="cross-stack-bucket" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file cfn/bucket.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/cross-reference-stacks/bin/deploy_main: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="cross-stack-main" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file cfn/template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/cross-reference-stacks/cfn/bucket.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Resources: 4 | S3Bucket: 5 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucket.html 6 | Type: AWS::S3::Bucket 7 | Properties: 8 | Tags: 9 | - Key: Hello 10 | Value: World 11 | Outputs: 12 | BucketName: 13 | Description: BucketName 14 | Value: !Ref S3Bucket 15 | Export: 16 | Name: !Sub ${AWS::StackName}BucketName -------------------------------------------------------------------------------- /cfn/cross-reference-stacks/cfn/template.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Parameters: 4 | BucketStack: 5 | Type: String 6 | Default: cross-stack-bucket 7 | Resources: 8 | MyEC2Instance: 9 | Type: AWS::EC2::Instance 10 | Properties: 11 | ImageId: "ami-07117708253546063" 12 | InstanceType: t3.micro 13 | Tags: 14 | - Key: AssociatedBucket 15 | Value: 16 | Fn::ImportValue: 17 | !Sub "${BucketStack}BucketName" -------------------------------------------------------------------------------- /cfn/depends/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="depends-on-2" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/drift-detection/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy drift detection alb with ec2" 4 | 5 | STACK_NAME="drift-alb-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/import/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="cfn-import" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/import/template.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Parameters: 4 | BucketName: 5 | Type: String 6 | Resources: 7 | S3Bucket: 8 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucket.html 9 | Type: AWS::S3::Bucket 10 | DeletionPolicy: Delete 11 | Properties: 12 | BucketName: 13 | Ref: BucketName 14 | Tags: 15 | - Key: Hello 16 | Value: World -------------------------------------------------------------------------------- /cfn/intrinsic/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="intrinsic" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/nested-stacks/Readme.md: -------------------------------------------------------------------------------- 1 | aws s3 cp s3_bucket.template s3://my-nested-stack-templates-233252 -------------------------------------------------------------------------------- /cfn/nested-stacks/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="nested-stacks" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/nested-stacks/s3_bucket.template: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Parameters: 4 | BucketName: 5 | Type: String 6 | Default: example-cfn-325252 7 | Resources: 8 | S3Bucket: 9 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucket.html 10 | Type: AWS::S3::Bucket 11 | Properties: 12 | BucketName: 13 | Ref: BucketName 14 | Tags: 15 | - Key: Hello 16 | Value: World -------------------------------------------------------------------------------- /cfn/nested-stacks/template.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Resources: 4 | MyStack: 5 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stack.html 6 | Type: AWS::CloudFormation::Stack 7 | Properties: 8 | TemplateURL: https://my-nested-stack-templates-233252.s3.ca-central-1.amazonaws.com/s3_bucket.template -------------------------------------------------------------------------------- /cfn/prevent-stack-update/Readme.md: -------------------------------------------------------------------------------- 1 | https://docs.aws.amazon.com/cli/latest/reference/cloudformation/set-stack-policy.html#examples 2 | 3 | ```sh 4 | aws cloudformation set-stack-policy \ 5 | --stack-name prevent-stack-update \ 6 | --stack-policy-body '{"Statement" : [{ 7 | "Effect" : "Deny", 8 | "Action" : "Update:*", 9 | "Principal": "*", 10 | "Resource" : "LogicalResourceId/MyEC2Instance" 11 | }]}' 12 | ``` -------------------------------------------------------------------------------- /cfn/prevent-stack-update/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="prevent-stack-update" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/prevent-stack-update/template.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Resources: 4 | MyEC2Instance: 5 | Type: AWS::EC2::Instance 6 | Properties: 7 | ImageId: "ami-07117708253546063" 8 | InstanceType: t3.small -------------------------------------------------------------------------------- /cfn/pseudo/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="pseudo-example" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/pseudo/template.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Parameters: 4 | BucketName: 5 | Type: String 6 | Default: example-cfn-32523552 7 | Resources: 8 | S3Bucket: 9 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucket.html 10 | Type: AWS::S3::Bucket 11 | Properties: 12 | BucketName: 13 | Ref: BucketName 14 | Tags: 15 | - Key: Region 16 | Value: !Ref AWS::Region 17 | - Key: StackName 18 | Value: !Ref AWS::StackName 19 | - Key: AccountId 20 | Value: !Ref AWS::AccountId -------------------------------------------------------------------------------- /cfn/quickstarts/Readme.md: -------------------------------------------------------------------------------- 1 | https://aws.amazon.com/solutions/implementations/amazon-rds-postgresql/ -------------------------------------------------------------------------------- /cfn/skip-delete-resource/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="skip-delete-resource" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/skip-delete-resource/hello.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cfn/skip-delete-resource/hello.txt -------------------------------------------------------------------------------- /cfn/stack-updates/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="stack-update" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cfn/stack-updates/template.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Parameters: 4 | BucketName: 5 | Type: String 6 | Default: example-cfn-325252 7 | Resources: 8 | S3Bucket: 9 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucket.html 10 | Type: AWS::S3::Bucket 11 | Properties: 12 | BucketName: 13 | Ref: BucketName 14 | Tags: 15 | - Key: Hello 16 | Value: World 17 | MyEC2Instance: 18 | Type: AWS::EC2::Instance 19 | Properties: 20 | ImageId: "ami-07117708253546063" 21 | InstanceType: t4g.micro -------------------------------------------------------------------------------- /cfn/wait-conditions/Readme.md: -------------------------------------------------------------------------------- 1 | /opt/aws/bin/cfn-signal -e $? --stack $wait-conditions --region ca-central-1 "https://cloudformation-waitcondition-ca-central-1.s3.ca-central-1.amazonaws.com/arn%3Aaws%3Acloudformation%3Aca-central-1%3A982383527471%3Astack/wait-conditions-2/cfeefcc0-0cb3-11ef-8387-06f17ac8a5bd/e1d47050-0cb3-11ef-ae26-0afda76d386b/WaitHandle?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20240507T205342Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86399&X-Amz-Credential=AKIAVYHELKCFXWIARSDU%2F20240507%2Fca-central-1%2Fs3%2Faws4_request&X-Amz-Signature=29b8c49b258349d3fc9cbe8f6c72d18729e3312884e86944619d71ba60785e92" -------------------------------------------------------------------------------- /cfn/wait-conditions/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | STACK_NAME="wait-conditions-3" 4 | 5 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 6 | aws cloudformation deploy \ 7 | --template-file template.yaml \ 8 | --capabilities CAPABILITY_NAMED_IAM \ 9 | --no-execute-changeset \ 10 | --region ca-central-1 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cloud9/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy cloud9" 4 | 5 | STACK_NAME="aws-cloud9-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /cloud9/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: "2010-09-09" 2 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instance.html 3 | Parameters: 4 | InstanceType: 5 | Type: String 6 | Default: t3.micro 7 | ImageId: 8 | Type: String 9 | # ca-central-1 AMI 10 | Default: ami-031a54947ff0e2af3 11 | SubnetId: 12 | Type: String 13 | Default: subnet-0e0fd31733061237d 14 | Resources: 15 | Cloud9: 16 | Type: AWS::Cloud9::EnvironmentEC2 17 | Properties: 18 | Name: MyTestEnv 19 | ImageId: !Ref ImageId 20 | InstanceType: !Ref InstanceType 21 | Description: My Test Env 22 | AutomaticStopTimeMinutes: 30 23 | ConnectionType: CONNECT_SSM 24 | SubnetId: !Ref SubnetId -------------------------------------------------------------------------------- /cloudtrail/basic/Readme.md: -------------------------------------------------------------------------------- 1 | # Create a bucket for cloudtrail logs 2 | 3 | aws s3 mb s3://my-cloudtrail-ab-1212 4 | 5 | # Create bucket policy to allow cloud trail to put to bucket 6 | 7 | aws s3api put-bucket-policy --bucket my-cloudtrail-ab-1212 --policy file://bucket-policy.json 8 | 9 | # Create Trail 10 | aws cloudtrail create-trail \ 11 | --name MyTrail \ 12 | --s3-bucket-name my-cloudtrail-ab-1212 \ 13 | --region ca-central-1 14 | 15 | # Start Logging 16 | 17 | aws cloudtrail start-logging --name MyTrail 18 | -------------------------------------------------------------------------------- /cloudtrail/basic/bucket-policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Sid": "AWSCloudTrailWrite20150319", 6 | "Effect": "Allow", 7 | "Principal": {"Service": "cloudtrail.amazonaws.com"}, 8 | "Action": "s3:PutObject", 9 | "Resource": "arn:aws:s3:::my-cloudtrail-ab-1212/AWSLogs/myAccountID/*", 10 | "Condition": { 11 | "StringEquals": { 12 | "s3:x-amz-acl": "bucket-owner-full-control", 13 | "aws:SourceArn": "arn:aws:cloudtrail:ca-central-1:982383527471:trail/MyTrail" 14 | } 15 | } 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /cloudtrail/cloudwatch/Readme.md: -------------------------------------------------------------------------------- 1 | # Create CloudWatch Log and Stream 2 | 3 | aws logs create-log-group --log-group-name mycloudtrail 4 | 5 | # Update trail for CloudWatch Logs 6 | aws cloudtrail update-trail \ 7 | --name MyTrail \ 8 | --cloud-watch-logs-log-group-arn arn:aws:logs:ca-central-1:982383527471:log-group:mycloudtrail:* \ 9 | --cloud-watch-logs-role-arn arn:aws:iam::982383527471:role/MyCloudTrail2CloudWatchRole -------------------------------------------------------------------------------- /cloudtrail/cloudwatch/cloud-watch-policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | 6 | "Sid": "AWSCloudTrailCreateLogStream2014110", 7 | "Effect": "Allow", 8 | "Action": [ 9 | "logs:CreateLogStream" 10 | ], 11 | "Resource": [ 12 | "arn:aws:logs:ca-central-1:982383527471:log-group:mycloudtrail:log-stream:*" 13 | ] 14 | 15 | }, 16 | { 17 | "Sid": "AWSCloudTrailPutLogEvents20141101", 18 | "Effect": "Allow", 19 | "Action": [ 20 | "logs:PutLogEvents" 21 | ], 22 | "Resource": [ 23 | "arn:aws:logs:ca-central-1:982383527471:log-group:mycloudtrail:log-stream:*" 24 | ] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /cloudwatch/logs/agent/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'rake' 7 | gem 'ox' 8 | gem 'pry' -------------------------------------------------------------------------------- /cloudwatch/logs/agent/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | coderay (1.1.3) 5 | method_source (1.1.0) 6 | ox (2.14.18) 7 | pry (0.14.2) 8 | coderay (~> 1.1) 9 | method_source (~> 1.0) 10 | rake (13.2.1) 11 | 12 | PLATFORMS 13 | ruby 14 | x86_64-linux 15 | 16 | DEPENDENCIES 17 | ox 18 | pry 19 | rake 20 | 21 | BUNDLED WITH 22 | 2.5.9 23 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/Rakefile: -------------------------------------------------------------------------------- 1 | require_relative 'data_generator.rb' 2 | 3 | task :run do 4 | DataGenerator.run( 5 | base_url: "http://15.157.62.176:3000" 6 | ) 7 | end -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-3.2.4 2 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "from@example.com" 3 | layout "mailer" 4 | end 5 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/app/models/concerns/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/bin/docker-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # If running the rails server then create or migrate existing database 4 | if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then 5 | ./bin/rails db:prepare 6 | fi 7 | 8 | exec "${@}" 9 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: shogun_production 11 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | 2FDSbab48T8ftVudqDi1H6xDy19mPWAokZR0oNPMtVnd5nOYgllrMvtCOVks6nr8UA36W3MqbMPgL1PDkyRmEqRnF/PeMAiqBCEQVVUpaHRKl+3JdxAkF+TJDZjo0b0/AjV8LUEE7PlIFb5w7zLx7r7o2GVRFhhOy1+WIqrqKbQcbFKipzsKrmZ0rqvLuREZkCRu6nwnBWzOtaGp8IPn91w5ypbTso/lt9xz5QK/vkN7+g0gaJ9MGit6NFyHhL5wDZ3gaBgrf/eo8KJqLwX9l+cLliVWzUPRdQG126/Vm3j8LrYLBM6XNAlioRxIr27OHRexLZxTVHCLgDYpLAVSQ7yejbEl5jOUMMXyu94revHU3re+He0gcQPh3MK04JRpxFTEiGWI+hjEKrC0Lrs4zMW0dMyC--nYP4v5Uo9T37VW1t--/dnopXrjYEgw1CBIqTHsLQ== -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: sqlite3 3 | database: db/development.sqlite3 4 | pool: 5 5 | timeout: 5000 6 | 7 | production: 8 | adapter: sqlite3 9 | database: db/production.sqlite3 10 | pool: 5 11 | timeout: 5000 -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config/initializers/cors.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Avoid CORS issues when API is called from the frontend app. 4 | # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests. 5 | 6 | # Read more: https://github.com/cyu/rack-cors 7 | 8 | # Rails.application.config.middleware.insert_before 0, Rack::Cors do 9 | # allow do 10 | # origins "example.com" 11 | # 12 | # resource "*", 13 | # headers: :any, 14 | # methods: [:get, :post, :put, :patch, :delete, :options, :head] 15 | # end 16 | # end 17 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. 4 | # Use this to limit dissemination of sensitive information. 5 | # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 8 | ] 9 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should ensure the existence of records required to run the application in every environment (production, 2 | # development, test). The code here should be idempotent so that it can be executed at any point in every environment. 3 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 4 | # 5 | # Example: 6 | # 7 | # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| 8 | # MovieGenre.find_or_create_by!(name: genre_name) 9 | # end 10 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/lib/tasks/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/log/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/storage/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/test/channels/application_cable/connection_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | module ApplicationCable 4 | class ConnectionTest < ActionCable::Connection::TestCase 5 | # test "connects with cookies" do 6 | # cookies.signed[:user_id] = 42 7 | # 8 | # connect 9 | # 10 | # assert_equal connection.user_id, "42" 11 | # end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/test/controllers/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/test/fixtures/files/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/test/fixtures/files/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/test/integration/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/test/mailers/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/test/models/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] ||= "test" 2 | require_relative "../config/environment" 3 | require "rails/test_help" 4 | 5 | module ActiveSupport 6 | class TestCase 7 | # Run tests in parallel with specified workers 8 | parallelize(workers: :number_of_processors) 9 | 10 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 11 | fixtures :all 12 | 13 | # Add more helper methods to be used by all tests here... 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/tmp/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/shogun/vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/cloudwatch/logs/agent/shogun/vendor/.keep -------------------------------------------------------------------------------- /cloudwatch/logs/agent/upload: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | MYPATH=/workspace/AWS-Examples/cloudwatch/logs/agent/shogun 3 | 4 | BUCKET=cw-agent-app-325252 5 | REGION=ca-central-1 6 | 7 | rm $MYPATH/app.zip 8 | 9 | pushd $MYPATH 10 | zip -r app.zip ./ 11 | popd 12 | 13 | aws s3 rm s3://$BUCKET/app.zip --region $REGION 14 | aws s3 cp $MYPATH/app.zip s3://$BUCKET --region $REGION 15 | rm $MYPATH/app.zip -------------------------------------------------------------------------------- /cloudwatch/logs/basic/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'nokogiri' # saw 7 | gem 'pry' 8 | gem 'aws-sdk-cloudwatchlogs' 9 | gem 'rake' -------------------------------------------------------------------------------- /cloudwatch/logs/basic/Rakefile: -------------------------------------------------------------------------------- 1 | require_relative 'put_logs.rb' 2 | 3 | task :log do 4 | PutLogs.run( 5 | log_group_name: '/example/basic/app', 6 | log_stream_name: Time.now.to_i.to_s, 7 | log_file_path: 'web_server_logs.log' 8 | ) 9 | end -------------------------------------------------------------------------------- /cloudwatch/logs/events/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'nokogiri' # saw 7 | gem 'pry' 8 | gem 'aws-sdk-cloudwatchlogs' 9 | gem 'rake' -------------------------------------------------------------------------------- /cloudwatch/logs/events/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create Logging Data 2 | 3 | ```sh 4 | python generate_json_logs.py > web_server_logs.json 5 | ``` 6 | 7 | # Filter Even Data 8 | 9 | ```sh 10 | aws logs filter-log-events \ 11 | --log-group-name /example/events/json/app \ 12 | --filter-pattern '{ $.method = "PUT" }' \ 13 | --start-time 1717043643000 \ 14 | --end-time 1717076943000 \ 15 | --query events[].message \ 16 | --output text 17 | ``` -------------------------------------------------------------------------------- /codepipeline/v1/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "v1", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "start": "node app.js", 7 | "dev": "nodemon --exec babel-node src/app.js", 8 | "build": "babel src -d dist" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "description": "", 14 | "dependencies": { 15 | "express": "^4.19.2" 16 | }, 17 | "devDependencies": { 18 | "@babel/cli": "^7.14.5", 19 | "@babel/core": "^7.14.6", 20 | "@babel/node": "^7.14.7", 21 | "@babel/preset-env": "^7.14.7", 22 | "nodemon": "^2.0.7" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /codepipeline/v1/app/src/app.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const path = require('path'); 3 | 4 | const app = express(); 5 | const port = process.env.PORT || 3000; 6 | 7 | // Serve static files from the 'public' directory 8 | app.use(express.static('public')); 9 | 10 | // Root route 11 | app.get('/', (req, res) => { 12 | res.sendFile(path.join(__dirname, 'public', 'index.html')); 13 | }); 14 | 15 | // API route 16 | app.get('/api/hello', (req, res) => { 17 | res.json({ message: 'Hello from Express!' }); 18 | }); 19 | 20 | // Start the server 21 | app.listen(port, () => { 22 | console.log(`Server running on http://localhost:${port}`); 23 | }); -------------------------------------------------------------------------------- /codepipeline/v1/aws/codebuild/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | install: 5 | runtime-versions: 6 | nodejs: 20 7 | commands: 8 | - npm install -g npm@latest 9 | pre_build: 10 | commands: 11 | - echo Installing source NPM dependencies... 12 | - npm install 13 | build: 14 | commands: 15 | - echo Build started on `date` 16 | - npm run build 17 | post_build: 18 | commands: 19 | - echo Build completed on `date` 20 | 21 | artifacts: 22 | files: 23 | - "**/*" 24 | base-directory: '.' 25 | name: express-app-$(date +%Y-%m-%d-%H-%M-%S).zip -------------------------------------------------------------------------------- /codepipeline/v1/aws/codedeploy/appspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.0 2 | os: linux 3 | files: 4 | - source: / 5 | destination: /var/www/express-app 6 | hooks: 7 | BeforeInstall: 8 | - location: scripts/before_install.sh 9 | timeout: 300 10 | runas: root 11 | AfterInstall: 12 | - location: scripts/after_install.sh 13 | timeout: 300 14 | runas: root 15 | ApplicationStart: 16 | - location: scripts/start_application.sh 17 | timeout: 300 18 | runas: root 19 | ApplicationStop: 20 | - location: scripts/stop_application.sh 21 | timeout: 300 22 | runas: root -------------------------------------------------------------------------------- /codepipeline/v1/aws/codedeploy/scripts/after_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /var/www/express-app 3 | npm install -------------------------------------------------------------------------------- /codepipeline/v1/aws/codedeploy/scripts/before_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Install dependencies 3 | sudo yum update -y 4 | sudo yum install -y nodejs npm -------------------------------------------------------------------------------- /codepipeline/v1/aws/codedeploy/scripts/start_application.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /var/www/express-app 3 | npm start & -------------------------------------------------------------------------------- /codepipeline/v1/aws/codedeploy/scripts/stop_application.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pkill node -------------------------------------------------------------------------------- /codepipeline/v1/bin/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy-codepipeline" 4 | 5 | STACK_NAME="aws-codepipeline-v1" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file ./aws/cfn/template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME \ 14 | --parameter-overrides \ 15 | CodeCommitRepoName="express-simple-ab" -------------------------------------------------------------------------------- /codewhisper/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'curses' 7 | -------------------------------------------------------------------------------- /codewhisper/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | curses (1.4.4) 5 | 6 | PLATFORMS 7 | ruby 8 | x86_64-linux 9 | 10 | DEPENDENCIES 11 | curses 12 | 13 | BUNDLED WITH 14 | 2.5.9 15 | -------------------------------------------------------------------------------- /codewhisper/game.rb: -------------------------------------------------------------------------------- 1 | # A game class for a terminal game that will be a simple game of black jack 2 | class Game 3 | attr_accessor :player, :dealer, :deck 4 | def initialize(player, dealer, deck) 5 | @player = player 6 | @dealer = dealer 7 | @deck = deck 8 | @deck.shuffle! 9 | @player.hand = [@deck.draw, @deck.draw] 10 | end 11 | -------------------------------------------------------------------------------- /copilot-cli/Readme.md: -------------------------------------------------------------------------------- 1 | ## Install AWS Copilot CLI 2 | 3 | ```sh 4 | brew install aws/tap/copilot-cli 5 | ``` 6 | 7 | ## Init a new copilot project 8 | 9 | ```sh 10 | copilot init 11 | ``` 12 | 13 | Path to our Dockerfile 14 | /workspace/AWS-Examples/ecr/app/Dockerfile -------------------------------------------------------------------------------- /datasync/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create Buckets 2 | 3 | ```sh 4 | aws s3 mb s3://source-datasync-32523 5 | aws s3 mb s3://dest-datasync-32523 6 | ``` 7 | 8 | # Upload File 9 | 10 | ```sh 11 | touch hello.txt 12 | aws s3 cp hello.txt s3://source-datasync-32523/data/hello.txt 13 | ``` -------------------------------------------------------------------------------- /datasync/hello.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/datasync/hello.txt -------------------------------------------------------------------------------- /device-farm/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'appium_lib_core' 7 | gem 'test-unit' 8 | -------------------------------------------------------------------------------- /device-farm/HelloWorld.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/device-farm/HelloWorld.apk -------------------------------------------------------------------------------- /dms/serverless/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Install MySQL and PSQL Client 3 | 4 | ```sh 5 | sudo apt-get install -y postgresql-client 6 | sudo apt-get install -y mysql-client 7 | ``` 8 | 9 | ## Assemble PSQL Connection String 10 | 11 | postgresql://postgres:password@:3306/mydatabase 12 | 13 | ## Assemble MySQL Connection String 14 | 15 | mysql://admin:password@:5432/mydatabase 16 | 17 | 18 | mysql -u admin -ppassword -h database-2.ck6c4llggxsy.us-east-1.rds.amazonaws.com -P 5432 database 19 | psql postgresql://postgres:password@rds-dms-postgres-rdsinstance-ghj0ttbqkmaf.cv1x0r3utzcm.ca-central-1.rds.amazonaws.com:3306/mydatabase 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /dms/serverless/bin/deploy_mysql: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy rds" 4 | 5 | STACK_NAME="rds-dms-mysql" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file cfn/mysql.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --parameter-overrides VpcId="vpc-08f0ec02f7471b018" Subnets="subnet-0e0fd31733061237d,subnet-0377c6b172e2951d4,subnet-0d8058cb02f147a86" \ 13 | --region ca-central-1 \ 14 | --stack-name $STACK_NAME 15 | -------------------------------------------------------------------------------- /dms/serverless/bin/deploy_postgres: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy rds" 4 | 5 | STACK_NAME="rds-dms-postgres" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file cfn/postgres.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --parameter-overrides VpcId="vpc-08f0ec02f7471b018" Subnets="subnet-0e0fd31733061237d,subnet-0377c6b172e2951d4,subnet-0d8058cb02f147a86" \ 13 | --region us-east-1 \ 14 | --stack-name $STACK_NAME 15 | -------------------------------------------------------------------------------- /dms/serverless/mysql.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE example_table ( 2 | id INT AUTO_INCREMENT PRIMARY KEY, 3 | name VARCHAR(50), 4 | age INT, 5 | created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 6 | salary DECIMAL(10,2), 7 | is_active BOOLEAN 8 | ); -------------------------------------------------------------------------------- /dms/serverless/postgres.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE example_table ( 2 | id SERIAL PRIMARY KEY, 3 | name VARCHAR(50), 4 | age INT, 5 | created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, 6 | salary DECIMAL(10, 2), 7 | is_active BOOLEAN 8 | ); -------------------------------------------------------------------------------- /documentdb/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'ox' 7 | gem 'mongo' 8 | gem 'pry' -------------------------------------------------------------------------------- /documentdb/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | bson (5.0.0) 5 | coderay (1.1.3) 6 | method_source (1.0.0) 7 | mongo (2.20.0) 8 | bson (>= 4.14.1, < 6.0.0) 9 | ox (2.14.18) 10 | pry (0.14.2) 11 | coderay (~> 1.1) 12 | method_source (~> 1.0) 13 | 14 | PLATFORMS 15 | ruby 16 | x86_64-linux 17 | 18 | DEPENDENCIES 19 | mongo 20 | ox 21 | pry 22 | 23 | BUNDLED WITH 24 | 2.5.6 25 | -------------------------------------------------------------------------------- /dynamodb/basic/bin/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | echo "== deploy ddb basic" 5 | 6 | STACK_NAME="dbb-basic" 7 | 8 | root_path=$(realpath .) 9 | template_path="${root_path}/template.yaml" 10 | 11 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 12 | aws cloudformation deploy \ 13 | --template-file "${template_path}" \ 14 | --capabilities CAPABILITY_NAMED_IAM \ 15 | --no-execute-changeset \ 16 | --region ca-central-1 \ 17 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /dynamodb/simple/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions] 4 | 5 | [layer_build_definitions] 6 | -------------------------------------------------------------------------------- /dynamodb/simple/.aws-sam/build/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | SimpleTable: 5 | Type: AWS::Serverless::SimpleTable 6 | -------------------------------------------------------------------------------- /dynamodb/simple/bin/put: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | root_path=$(realpath .) 5 | item_path="file://${root_path}/item.json" 6 | 7 | DDB=db-table-SimpleTable-KIOIT44C54TP 8 | 9 | aws dynamodb put-item \ 10 | --table-name $DDB \ 11 | --item $item_path -------------------------------------------------------------------------------- /dynamodb/simple/item.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": { 3 | "S": "hello" 4 | }, 5 | "fruit": { 6 | "S": "Apple" 7 | } 8 | } -------------------------------------------------------------------------------- /dynamodb/simple/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion : '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | SimpleTable: 5 | Type : AWS::Serverless::SimpleTable -------------------------------------------------------------------------------- /eb/advanced/.gitignore: -------------------------------------------------------------------------------- 1 | myenv/* 2 | # Elastic Beanstalk Files 3 | .elasticbeanstalk/* 4 | !.elasticbeanstalk/*.cfg.yml 5 | !.elasticbeanstalk/*.global.yml 6 | -------------------------------------------------------------------------------- /eb/advanced/app/.elasticbeanstalk/config.yml: -------------------------------------------------------------------------------- 1 | branch-defaults: 2 | default: 3 | environment: null 4 | group_suffix: null 5 | global: 6 | application_name: study-sync 7 | branch: null 8 | default_ec2_keyname: aws-eb 9 | default_platform: Node.js 20 running on 64bit Amazon Linux 2023 10 | default_region: ca-central-1 11 | include_git_submodules: true 12 | instance_profile: null 13 | platform_name: null 14 | platform_version: null 15 | profile: null 16 | repository: null 17 | sc: null 18 | workspace_type: Application 19 | -------------------------------------------------------------------------------- /eb/advanced/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Study-Sync 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eb/advanced/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "dependencies": { 7 | "express": "^4.17.1", 8 | "pg": "^8.11.5" 9 | }, 10 | "scripts": { 11 | "start": "node index.js", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /eb/advanced/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | db: 4 | image: postgres:13-alpine 5 | restart: always 6 | environment: 7 | - POSTGRES_USER=postgres 8 | - POSTGRES_PASSWORD=password 9 | ports: 10 | - '5432:5432' 11 | volumes: 12 | - db:/var/lib/postgresql/data 13 | volumes: 14 | db: 15 | driver: local -------------------------------------------------------------------------------- /eb/advanced/rds/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy rds" 4 | 5 | STACK_NAME="rds-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --parameter-overrides VpcId="vpc-08f0ec02f7471b018" WebServerSGGroupId="sg-075794ee8d69d71af" Subnets="subnet-0e0fd31733061237d,subnet-0377c6b172e2951d4,subnet-0d8058cb02f147a86" \ 13 | --region ca-central-1 \ 14 | --stack-name $STACK_NAME 15 | 16 | 17 | -------------------------------------------------------------------------------- /eb/advanced/sql/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; 2 | 3 | DROP TABLE IF EXISTS answers; 4 | DROP TABLE IF EXISTS questions; 5 | 6 | CREATE TABLE public.answers ( 7 | uuid UUID DEFAULT uuid_generate_v4() PRIMARY KEY, 8 | question_uuid UUID NOT NULL, 9 | choice CHAR(1) NOT NULL, 10 | is_correct BOOLEAN NOT NULL, 11 | created_at TIMESTAMP default current_timestamp NOT NULL 12 | ); 13 | 14 | CREATE TABLE public.questions ( 15 | uuid UUID DEFAULT uuid_generate_v4() PRIMARY KEY, 16 | question TEXT NOT NULL, 17 | option_a TEXT NOT NULL, 18 | option_b TEXT NOT NULL, 19 | option_c TEXT NOT NULL, 20 | option_d TEXT NOT NULL, 21 | correct_answer CHAR(1) NOT NULL 22 | ); -------------------------------------------------------------------------------- /eb/basic/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | db: 4 | image: postgres:13-alpine 5 | restart: always 6 | environment: 7 | - POSTGRES_USER=postgres 8 | - POSTGRES_PASSWORD=password 9 | ports: 10 | - '5432:5432' 11 | volumes: 12 | - db:/var/lib/postgresql/data 13 | volumes: 14 | db: 15 | driver: local -------------------------------------------------------------------------------- /eb/basic/example/.ebextensions/init.config: -------------------------------------------------------------------------------- 1 | commands: 2 | setvars: 3 | command: /opt/elasticbeanstalk/bin/get-config environment | jq -r 'to_entries | .[] | "export \(.key)=\"\(.value)\""' > /etc/profile.d/sh.local -------------------------------------------------------------------------------- /eb/basic/example/.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-3.2.3 2 | -------------------------------------------------------------------------------- /eb/basic/example/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /eb/basic/example/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /eb/basic/example/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/app/assets/images/.keep -------------------------------------------------------------------------------- /eb/basic/example/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* Application styles */ 2 | -------------------------------------------------------------------------------- /eb/basic/example/app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /eb/basic/example/app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /eb/basic/example/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | def home 3 | @things = Thing.all 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /eb/basic/example/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /eb/basic/example/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /eb/basic/example/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /eb/basic/example/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "from@example.com" 3 | layout "mailer" 4 | end 5 | -------------------------------------------------------------------------------- /eb/basic/example/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /eb/basic/example/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/app/models/concerns/.keep -------------------------------------------------------------------------------- /eb/basic/example/app/models/thing.rb: -------------------------------------------------------------------------------- 1 | class Thing < ApplicationRecord 2 | end -------------------------------------------------------------------------------- /eb/basic/example/app/views/application/home.html.erb: -------------------------------------------------------------------------------- 1 | <%- @things.each do |thing| %> 2 |
3 | <%= thing.name %> 4 |
5 | <%- end %> -------------------------------------------------------------------------------- /eb/basic/example/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Example 5 | 6 | <%= csrf_meta_tags %> 7 | <%= csp_meta_tag %> 8 | 9 | <%= stylesheet_link_tag "application" %> 10 | 11 | 12 | 13 | <%= yield %> 14 | 15 | 16 | -------------------------------------------------------------------------------- /eb/basic/example/app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /eb/basic/example/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /eb/basic/example/bin/docker-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # If running the rails server then create or migrate existing database 4 | if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then 5 | ./bin/rails db:prepare 6 | fi 7 | 8 | exec "${@}" 9 | -------------------------------------------------------------------------------- /eb/basic/example/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /eb/basic/example/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /eb/basic/example/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /eb/basic/example/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /eb/basic/example/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: example_production 11 | -------------------------------------------------------------------------------- /eb/basic/example/config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | d7n+BcxCmR6ECzL1jmpk0nMLf1iXAY2RJ8yDaEMGPc9EmJaf0mMf4VMFRr8WMikfm/gIXvIm2FMUbpEs2oEtrSzqwhXE+KYQKWOTACwFoKVlrJF8hzvoBhLhlrXAn/0F93wnkdpjVfxNw/4jr4eBmMo152wBNHLYUhcR4WFcHzO1C+XM57gJ1+eN6PfBdlloUK2NkExVFE1VyXlQNKyC81LFMbXfSRQShXUF0iozoaqiyBfirJQCgwBCeibvEenRWVHV0vJAtETt1ao+whZx0FI83cvizdSd9GJftLS4PqDsfCTBsObp38T+9uD4qUqncZ8k4A05O0J8URXnesM+OZB6MSjnPekD6tExAB9Z1SckUTNSHs5SRgRo9UjAeZqs01dNbDJgBSv08ZhuGE8jpXWN39rZ--/JSF37A00AfPDyBq--F/kJ8ufKzx2T+5oMyKh0Rw== -------------------------------------------------------------------------------- /eb/basic/example/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /eb/basic/example/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. 4 | # Use this to limit dissemination of sensitive information. 5 | # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 8 | ] 9 | -------------------------------------------------------------------------------- /eb/basic/example/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym "RESTful" 16 | # end 17 | -------------------------------------------------------------------------------- /eb/basic/example/config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide HTTP permissions policy. For further 4 | # information see: https://developers.google.com/web/updates/2018/06/feature-policy 5 | 6 | # Rails.application.config.permissions_policy do |policy| 7 | # policy.camera :none 8 | # policy.gyroscope :none 9 | # policy.microphone :none 10 | # policy.usb :none 11 | # policy.fullscreen :self 12 | # policy.payment :self, "https://secure.example.com" 13 | # end 14 | -------------------------------------------------------------------------------- /eb/basic/example/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html 3 | 4 | # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. 5 | # Can be used by load balancers and uptime monitors to verify that the app is live. 6 | get "up" => "rails/health#show", as: :rails_health_check 7 | 8 | # Defines the root path route ("/") 9 | root "application#home" 10 | end 11 | -------------------------------------------------------------------------------- /eb/basic/example/db/migrate/20240304193005_create_tables.rb: -------------------------------------------------------------------------------- 1 | class CreateTables < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :things do |t| 4 | t.string :name 5 | t.timestamps 6 | end 7 | 8 | Thing.create!(name: "Hello") 9 | Thing.create!(name: "World") 10 | Thing.create!(name: "Goodbye") 11 | Thing.create!(name: "Moon") 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /eb/basic/example/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should ensure the existence of records required to run the application in every environment (production, 2 | # development, test). The code here should be idempotent so that it can be executed at any point in every environment. 3 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 4 | # 5 | # Example: 6 | # 7 | # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| 8 | # MovieGenre.find_or_create_by!(name: genre_name) 9 | # end 10 | -------------------------------------------------------------------------------- /eb/basic/example/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/lib/assets/.keep -------------------------------------------------------------------------------- /eb/basic/example/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/lib/tasks/.keep -------------------------------------------------------------------------------- /eb/basic/example/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/log/.keep -------------------------------------------------------------------------------- /eb/basic/example/public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /eb/basic/example/public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/public/apple-touch-icon.png -------------------------------------------------------------------------------- /eb/basic/example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/public/favicon.ico -------------------------------------------------------------------------------- /eb/basic/example/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /eb/basic/example/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/storage/.keep -------------------------------------------------------------------------------- /eb/basic/example/tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/tmp/.keep -------------------------------------------------------------------------------- /eb/basic/example/tmp/pids/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/tmp/pids/.keep -------------------------------------------------------------------------------- /eb/basic/example/tmp/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/tmp/storage/.keep -------------------------------------------------------------------------------- /eb/basic/example/vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/eb/basic/example/vendor/.keep -------------------------------------------------------------------------------- /ebs/basic/Readme.md: -------------------------------------------------------------------------------- 1 | ## Commands we used 2 | 3 | ```sh 4 | df -h 5 | lsblk 6 | sudo file -s /dev/xvdh 7 | sudo file -s /dev/sdh 8 | sudo mkfs -t xfs /dev/sdh 9 | sudo mkdir /newvolume 10 | sudo mount /dev/sdh /newvolume 11 | ``` -------------------------------------------------------------------------------- /ebs/basic/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy secrets manager stuff" 4 | 5 | STACK_NAME="aws-sm-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /ebs/encrypt/Readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/ebs/encrypt/Readme.md -------------------------------------------------------------------------------- /ebs/encrypt/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2 instance" 4 | 5 | STACK_NAME="aws-ebs-encrypt" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /ebs/multi-atttach/Readme.md: -------------------------------------------------------------------------------- 1 | https://docs.aws.amazon.com/ebs/latest/userguide/ebs-volumes-multi.html 2 | 3 | 4 | # Commands we used 5 | 6 | ## Format and Mount EC2 1 7 | 8 | ```sh 9 | sudo mkfs -t xfs /dev/sdh 10 | sudo mkdir /newvolume 11 | sudo mount /dev/sdh /newvolume 12 | cd /newvolume 13 | touch hello.txt 14 | ``` 15 | 16 | ## Just Mount EC2 2 17 | 18 | ```sh 19 | sudo mkdir /newvolume 20 | sudo mount /dev/sdh /newvolume 21 | ``` -------------------------------------------------------------------------------- /ebs/multi-atttach/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2 instance" 4 | 5 | STACK_NAME="aws-ebs-multi-attach" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region us-east-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /ebs/resize/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Modify Volume 3 | ```sh 4 | aws ec2 modify-volume --size 12 --volume-id vol-098b39dabf29eaa66 5 | ``` 6 | 7 | # Extend Filesystem 8 | 9 | ```sh 10 | sudo growpart /dev/nvme0n1 1 11 | sudo xfs_growfs -d / 12 | ``` 13 | 14 | > growpart is used to expand the partition to the whole disk. xfs_growfs is used to resize and apply the changes. 15 | 16 | https://docs.aws.amazon.com/ebs/latest/userguide/recognize-expanded-volume-linux.html 17 | https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-volume.html#examples -------------------------------------------------------------------------------- /ebs/resize/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2 instance" 4 | 5 | STACK_NAME="aws-ebs-resize" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /ec2/userdata/userdata.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Update system package repository 3 | sudo yum update -y 4 | 5 | # Install Apache (httpd) 6 | sudo yum install -y httpd 7 | 8 | # Start Apache service 9 | sudo systemctl start httpd 10 | 11 | # Enable Apache to start at boot 12 | sudo systemctl enable httpd 13 | 14 | # Create a custom HTML file 15 | cat < /var/www/html/index.html 16 | 17 | 18 | 19 | Welcome to My Website 20 | 21 | 22 |

Hello, World!

23 |

This is a custom HTML page served from my Apache server on EC2.

24 | 25 | 26 | EOF 27 | 28 | # Restart Apache to apply changes 29 | sudo systemctl restart httpd -------------------------------------------------------------------------------- /ec2/userdata/userdata.yml: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | 3 | package_update: true 4 | package_upgrade: true 5 | packages: 6 | - httpd 7 | 8 | write_files: 9 | - path: /var/www/html/index.html 10 | content: | 11 | 12 | 13 | 14 | Welcome to My Website 15 | 16 | 17 |

Hello, World!

18 |

This is a custom HTML page served from my Apache server on EC2.

19 | 20 | 21 | owner: root:root 22 | permissions: '0644' 23 | runcmd: 24 | - systemctl start httpd.service 25 | - systemctl enable httpd.service 26 | - systemctl restart httpd.service -------------------------------------------------------------------------------- /ecr/app/Readme.md: -------------------------------------------------------------------------------- 1 | Hello! -------------------------------------------------------------------------------- /ecr/app/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | from flask import request 3 | import os 4 | 5 | app = Flask(__name__) 6 | 7 | @app.route("/api/hello", methods=['GET']) 8 | def hello(): 9 | model = {'errors': None} 10 | name = request.args.get('name') 11 | if not name: 12 | model['errors'] = [{"msg": "Name not provided"}] 13 | else: 14 | model['data'] = {"msg": f"Hello {name}!"} 15 | 16 | if 'errors' in model and model['errors'] is not None: 17 | return model['errors'], 422 18 | else: 19 | return model['data'], 200 20 | 21 | if __name__ == "__main__": 22 | app.run(debug=True) -------------------------------------------------------------------------------- /ecr/app/requirements.txt: -------------------------------------------------------------------------------- 1 | flask -------------------------------------------------------------------------------- /ecs/ec2/Readme.md: -------------------------------------------------------------------------------- 1 | ## Get the ECS EC2 Optimized AMI 2 | 3 | https://docs.aws.amazon.com/AmazonECS/latest/developerguide/retrieve-ecs-optimized_AMI.html 4 | 5 | ```sh 6 | aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux-2023/recommended --region ca-central-1 7 | ``` 8 | 9 | > Swap the region for your usecase 10 | 11 | ## Create Log Group 12 | 13 | aws logs create-log-group --log-group-name ecs-ec2-basic 14 | 15 | ## Create our Task Def 16 | 17 | aws ecs register-task-definition --cli-input-json file://task-def.json 18 | 19 | ## Deploy Container 20 | 21 | aws ecs create-service --cli-input-json file://serv.json -------------------------------------------------------------------------------- /ecs/ec2/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ecs ec2" 4 | 5 | STACK_NAME="ecs-ec2-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /ecs/ec2/deploy-capacity-provider: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ecs ec2" 4 | 5 | STACK_NAME="ecs-ec2-cp" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file capacity-provider.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /ecs/ec2/policies/execution.json: -------------------------------------------------------------------------------- 1 | 2 | "ecr:GetAuthorizationToken", 3 | "ecr:BatchCheckLayerAvailability", 4 | "ecr:GetDownloadUrlForLayer", 5 | "ecr:BatchGetImage", 6 | "logs:CreateLogStream", 7 | "logs:PutLogEvents" -------------------------------------------------------------------------------- /ecs/ec2/policies/task.json: -------------------------------------------------------------------------------- 1 | 2 | ssmmessages:CreateControlChannel 3 | ssmmessages:CreateDataChannel 4 | ssmmessages:OpenControlChannel 5 | ssmmessages:OpenDataChannel 6 | 7 | arn:aws:iam:policy/CloudWatchLogsFullAccess 8 | -------------------------------------------------------------------------------- /ecs/ec2/serv.json: -------------------------------------------------------------------------------- 1 | { 2 | "cluster": "ecs-ec2-basicECSCluster", 3 | "launchType": "FARGATE", 4 | "desiredCount": 1, 5 | "enableECSManagedTags": true, 6 | "enableExecuteCommand": true, 7 | "propagateTags": "SERVICE", 8 | "serviceName": "app", 9 | "taskDefinition": "app" 10 | } -------------------------------------------------------------------------------- /ecs/fargate/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ecs fargate" 4 | 5 | STACK_NAME="ecs-fargate-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /ecs/fargate/serv.json: -------------------------------------------------------------------------------- 1 | { 2 | "cluster": "ecs-fargate-basicECSCluster", 3 | "launchType": "FARGATE", 4 | "desiredCount": 1, 5 | "enableECSManagedTags": true, 6 | "enableExecuteCommand": true, 7 | "propagateTags": "SERVICE", 8 | "serviceName": "app", 9 | "taskDefinition": "app", 10 | "networkConfiguration": { 11 | "awsvpcConfiguration": { 12 | "assignPublicIp": "ENABLED", 13 | "securityGroups": [ 14 | "sg-0342d7212d8203a78" 15 | ], 16 | "subnets": [ 17 | "subnet-0d8058cb02f147a86", 18 | "subnet-0e0fd31733061237d" 19 | ] 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /ecs/fargate/session-manager-plugin.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/ecs/fargate/session-manager-plugin.deb -------------------------------------------------------------------------------- /ecs/service-connect/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ecs fargate" 4 | 5 | STACK_NAME="ecs-fargate-sc" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /efs/basic/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | ## Setting UP 3 | 4 | ```sh 5 | sudo yum install -y amazon-efs-utils 6 | sudo mkdir /mnt/efs 7 | ``` 8 | 9 | ## Mounting 10 | 11 | ```sh 12 | sudo mount -t efs -o tls fs-0bf948f125e97f2d2:/ /mnt/efs 13 | ``` -------------------------------------------------------------------------------- /efs/basic/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2 instance" 4 | 5 | STACK_NAME="aws-efs-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /eks/node-role-trust-relationship.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Effect": "Allow", 6 | "Principal": { 7 | "Service": "ec2.amazonaws.com" 8 | }, 9 | "Action": "sts:AssumeRole" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /elastic-transcoder/App2Container.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/elastic-transcoder/App2Container.mp4 -------------------------------------------------------------------------------- /elastic-transcoder/content-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Bucket":"videos.example1254124.com", 3 | "Permissions":[{ 4 | "GranteeType": "Canonical", 5 | "Grantee": "982383527471", 6 | "Access": ["FullControl"] 7 | }], 8 | "StorageClass":"Standard" 9 | } -------------------------------------------------------------------------------- /elastic-transcoder/inputs.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "Key":"video.mp4", 3 | "FrameRate":"auto", 4 | "Resolution":"auto", 5 | "AspectRatio":"auto", 6 | "Interlaced":"auto", 7 | "Container":"mp4" 8 | }] -------------------------------------------------------------------------------- /elastic-transcoder/outputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Key":"webm/video.webm", 4 | "Rotate":"0", 5 | "PresetId":"1351620000001-100250" 6 | } 7 | ] -------------------------------------------------------------------------------- /elastic-transcoder/thumbnail-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Bucket":"videos.example1254124.com", 3 | "Permissions":[{ 4 | "GranteeType": "Canonical", 5 | "Grantee": "982383527471", 6 | "Access": ["FullControl"] 7 | }], 8 | "StorageClass":"Standard" 9 | } -------------------------------------------------------------------------------- /elastic-transcoder/user-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "Author":"Andrew Brown", 3 | "Topic": "Application2Container", 4 | "Category": "AWS" 5 | } -------------------------------------------------------------------------------- /elasticache/serverless/Readme.md: -------------------------------------------------------------------------------- 1 | # Create Serverless Cache 2 | 3 | aws elasticache create-serverless-cache \ 4 | --serverless-cache-name my-cache-ab-5252 \ 5 | --major-engine-version 7 6 | 7 | # Install Redis Client (Ubuntu) 8 | 9 | ```sh 10 | sudo apt-get install redis -y 11 | ``` 12 | 13 | # Connect to instance 14 | 15 | ```sh 16 | redis-cli -h my-cache-ab-5252-ehplt6.serverless.cac1.cache.amazonaws.com 17 | ``` -------------------------------------------------------------------------------- /elasticache/serverless/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2 instance to interact with redis" 4 | 5 | STACK_NAME="ec2-4-redis" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /elasticache/serverless/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' # Use Docker Compose file format 3.8 2 | 3 | services: 4 | redis: 5 | image: redis:7 # Use Redis version 7 6 | container_name: redis7 7 | ports: 8 | - "6379:6379" # Map port 6379 on the host to port 6379 in the container 9 | volumes: 10 | - redis_data:/data # Persist Redis data to a named volume 11 | 12 | volumes: 13 | redis_data: # Define the volume to persist Redis data -------------------------------------------------------------------------------- /elb/alb/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy alb with ec2" 4 | 5 | STACK_NAME="alb-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /fsx/openzfs/Readme.md: -------------------------------------------------------------------------------- 1 | https://docs.aws.amazon.com/fsx/latest/OpenZFSGuide/getting-started-step2.html 2 | 3 | 4 | -------------------------------------------------------------------------------- /global-accelerator/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy global acc" 4 | 5 | STACK_NAME="aws-global-acc-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /glue/data-catalog/.gitignore: -------------------------------------------------------------------------------- 1 | data/*.csv -------------------------------------------------------------------------------- /glue/data-catalog/data/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/glue/data-catalog/data/.keep -------------------------------------------------------------------------------- /glue/data-catalog/json/policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Effect": "Allow", 6 | "Action": [ 7 | "s3:GetObject", 8 | "s3:PutObject" 9 | ], 10 | "Resource": [ 11 | "arn:aws:s3:::glue-data-catalog-6163/*" 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /glue/data-catalog/json/trust-policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Effect": "Allow", 6 | "Principal": { 7 | "Service": "glue.amazonaws.com" 8 | }, 9 | "Action": "sts:AssumeRole" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /iam/policy/Readme.md: -------------------------------------------------------------------------------- 1 | ## Convert to json 2 | 3 | The command 4 | ```sh 5 | yq -o json policy.yml > policy.json 6 | ``` 7 | 8 | The bash script 9 | 10 | ```sh 11 | ./convert 12 | ``` 13 | 14 | # Create IAM Policy 15 | 16 | ```sh 17 | aws iam create-policy \ 18 | --policy-name my-fun-policy \ 19 | --policy-document file://policy.json 20 | ``` 21 | 22 | # Attach Policy to user 23 | 24 | ```sh 25 | aws iam attach-user-policy \ 26 | --policy-arn arn:aws:iam::982383527471:policy/my-fun-policy \ 27 | --user-name aws-examples 28 | ``` -------------------------------------------------------------------------------- /iam/policy/policy.yml: -------------------------------------------------------------------------------- 1 | Version: "2012-10-17" 2 | Statement: 3 | - Sid: "AccessToS3" 4 | Effect: "Allow" 5 | Action: "s3:ListBucket" 6 | Resource: 7 | - "*" -------------------------------------------------------------------------------- /iam/policy/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #yq -o json policy.yml > policy.json 4 | 5 | aws iam create-policy-version \ 6 | --policy-arn arn:aws:iam::982383527471:policy/my-fun-policy \ 7 | --policy-document "$(yq -o json policy.yml)" \ 8 | --set-as-default -------------------------------------------------------------------------------- /kafka/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | 7 | gem "karafka", ">= 2.4.0" 8 | -------------------------------------------------------------------------------- /kafka/app/consumers/application_consumer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Application consumer from which all Karafka consumers should inherit 4 | # You can rename it if it would conflict with your current code base (in case you're integrating 5 | # Karafka with other frameworks) 6 | class ApplicationConsumer < Karafka::BaseConsumer 7 | end 8 | -------------------------------------------------------------------------------- /kafka/app/consumers/example_consumer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Example consumer that prints messages payloads 4 | class ExampleConsumer < ApplicationConsumer 5 | def consume 6 | messages.each { |message| puts message.payload } 7 | end 8 | 9 | # Run anything upon partition being revoked 10 | # def revoked 11 | # end 12 | 13 | # Define here any teardown things you want when Karafka server stops 14 | # def shutdown 15 | # end 16 | end 17 | -------------------------------------------------------------------------------- /kafka/log/development.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kafka/log/development.log -------------------------------------------------------------------------------- /kendra/oliver-twist.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/oliver-twist.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part1.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part10.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part11.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part12.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part12.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part13.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part13.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part14.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part14.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part15.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part15.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part16.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part16.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part17.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part18.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part19.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part19.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part2.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part20.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part20.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part21.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part21.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part22.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part22.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part23.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part23.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part24.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part24.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part25.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part25.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part26.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part26.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part27.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part27.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part28.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part28.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part29.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part29.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part3.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part30.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part30.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part31.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part31.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part32.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part32.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part33.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part33.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part34.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part34.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part35.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part35.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part36.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part36.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part37.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part37.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part38.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part38.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part4.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part5.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part6.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part7.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part8.pdf -------------------------------------------------------------------------------- /kendra/split/oliver-twist_Part9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kendra/split/oliver-twist_Part9.pdf -------------------------------------------------------------------------------- /kinesis/datastreams/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy Data Stream" 4 | 5 | STACK_NAME="datastream" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /kinesis/datastreams/kpl-example/src/test/java/co/exampro/AppTest.java: -------------------------------------------------------------------------------- 1 | package co.exampro; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | { 12 | /** 13 | * Rigorous Test :-) 14 | */ 15 | @Test 16 | public void shouldAnswerWithTrue() 17 | { 18 | assertTrue( true ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /kinesis/datastreams/kpl-example/target/classes/co/exampro/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kinesis/datastreams/kpl-example/target/classes/co/exampro/App.class -------------------------------------------------------------------------------- /kinesis/datastreams/kpl-example/target/test-classes/co/exampro/AppTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/kinesis/datastreams/kpl-example/target/test-classes/co/exampro/AppTest.class -------------------------------------------------------------------------------- /kinesis/datastreams/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: "2010-09-09" 2 | Description: A Simple Kinesis Data Streams Provisioned 3 | Resources: 4 | MyStream: 5 | Type: AWS::Kinesis::Stream 6 | Properties: 7 | # Name: MyStream 8 | # RetentionPeriodHours: 24 9 | ShardCount: 1 10 | StreamModeDetails: 11 | StreamMode: PROVISIONED -------------------------------------------------------------------------------- /kinesis/firehose/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'aws-sdk-firehose' 7 | gem "nokogiri" 8 | gem 'pry' -------------------------------------------------------------------------------- /kinesis/firehose/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy Data Firehose with an s3 bucket via CFN" 4 | 5 | STACK_NAME="dataf-1212" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /kinesis/firehose/record.rb: -------------------------------------------------------------------------------- 1 | require 'aws-sdk-firehose' # Make sure to include aws-sdk-kinesis 2 | require 'pry' 3 | #require 'base64' 4 | 5 | # Initialize a Kinesis client 6 | client = Aws::Firehose::Client.new 7 | 8 | stream_name = 'dataf-1212-Firehose-gadcI69dfDSw' 9 | 10 | # Prepare records 11 | 10.times.map do |i| 12 | data = {hello: "world: #{i}"}.to_json 13 | response = client.put_record( 14 | delivery_stream_name: stream_name, 15 | record: {data: data} 16 | ) 17 | #binding.pry 18 | puts "Response: #{response.inspect}" 19 | end -------------------------------------------------------------------------------- /lambda/container/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions.65563a0d-eeb4-464a-92e5-6cd49ddb0ea0] 4 | packagetype = "Image" 5 | functions = ["InlineLambda"] 6 | 7 | [function_build_definitions.65563a0d-eeb4-464a-92e5-6cd49ddb0ea0.metadata] 8 | DockerContext = "../" 9 | Dockerfile = "Dockerfile" 10 | 11 | [layer_build_definitions] 12 | -------------------------------------------------------------------------------- /lambda/container/.aws-sam/build/packaged.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Metadata: 7 | DockerContext: ../ 8 | Dockerfile: Dockerfile 9 | SamResourceId: InlineLambda 10 | Properties: 11 | PackageType: Image 12 | ImageUri: 982383527471.dkr.ecr.ca-central-1.amazonaws.com/python-container-example:inlinelambda-1502e09db604-latest 13 | -------------------------------------------------------------------------------- /lambda/container/.aws-sam/build/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Metadata: 7 | DockerContext: ../ 8 | Dockerfile: Dockerfile 9 | SamResourceId: InlineLambda 10 | Properties: 11 | PackageType: Image 12 | ImageUri: inlinelambda:latest 13 | -------------------------------------------------------------------------------- /lambda/container/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use AWS python base image 2 | FROM public.ecr.aws/lambda/python:3.12 3 | 4 | # Copy over function specific code 5 | COPY function/function.py function/requirements.txt /var/task/ 6 | 7 | # Install requirements 8 | RUN python3.12 -m pip install -r /var/task/requirements.txt 9 | 10 | # Set the file function.py and the function handler as the lambda function. 11 | CMD ["function.handler"] -------------------------------------------------------------------------------- /lambda/container/bin/bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | aws ecr create-repository \ 5 | --repository-name python-container-example \ 6 | --image-tag-mutability IMMUTABLE \ 7 | --image-scanning-configuration scanOnPush=true -------------------------------------------------------------------------------- /lambda/container/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # we need the absolute path because relative path was giving us trouble 5 | root_path=$(realpath .) 6 | 7 | # cfn-lint 8 | # ------------------- 9 | # This will check our cloudformation template to ensure its valid format 10 | echo "== CFN linting..." 11 | cfn-lint "${root_path}/template.yml" -------------------------------------------------------------------------------- /lambda/container/function/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | from faker import Faker 3 | 4 | def handler(event, context): 5 | fake = Faker() 6 | message = 'Hello {}!'.format(fake.name()) 7 | info = { 8 | "Type": "Container Example", 9 | "Version": 1 10 | } 11 | info_json = json.dumps(info) 12 | print(info_json) 13 | return { 14 | 'message' : message 15 | } -------------------------------------------------------------------------------- /lambda/container/function/requirements.txt: -------------------------------------------------------------------------------- 1 | faker==24.1.0 -------------------------------------------------------------------------------- /lambda/container/samconfig.toml: -------------------------------------------------------------------------------- 1 | version=0.1 2 | [default.package.parameters] 3 | s3_bucket = "my-lambda-artifacts-ab-1512" 4 | region = "ca-central-1" 5 | image_repository="982383527471.dkr.ecr.ca-central-1.amazonaws.com/python-container-example" 6 | [default.deploy.parameters] 7 | s3_bucket = "my-lambda-artifacts-ab-1512" 8 | region = "ca-central-1" 9 | image_repository="982383527471.dkr.ecr.ca-central-1.amazonaws.com/python-container-example" -------------------------------------------------------------------------------- /lambda/container/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion : '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html 5 | InlineLambda: 6 | Type: AWS::Serverless::Function 7 | Metadata: 8 | DockerContext: "../" 9 | Dockerfile: Dockerfile 10 | Properties: 11 | PackageType: Image -------------------------------------------------------------------------------- /lambda/inline/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions] 4 | 5 | [layer_build_definitions] 6 | -------------------------------------------------------------------------------- /lambda/inline/.aws-sam/build/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Properties: 7 | Handler: index.handler 8 | Runtime: python3.12 9 | PackageType: Zip 10 | InlineCode: "def handler(event, context):\n message = 'Hello {} {}!'.format(event['first_name'],\ 11 | \ event['last_name']) \n print(\"Log this for me\")\n return { \n \ 12 | \ 'message' : message\n }" 13 | -------------------------------------------------------------------------------- /lambda/inline/Readme.md: -------------------------------------------------------------------------------- 1 | # Install SAM CLI 2 | 3 | ```sh 4 | ./bin/aws_sam_cli_install.sh 5 | ``` 6 | 7 | # Install CFN Lint 8 | 9 | ```sh 10 | brew install cfn-lint 11 | ``` 12 | 13 | ## Build and Deploy 14 | 15 | ```sh 16 | sam build 17 | sam deploy 18 | ``` -------------------------------------------------------------------------------- /lambda/inline/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # we need the absolute path because relative path was giving us trouble 5 | root_path=$(realpath .) 6 | 7 | # cfn-lint 8 | # ------------------- 9 | # This will check our cloudformation template to ensure its valid format 10 | echo "== CFN linting..." 11 | cfn-lint "${root_path}/template.yml" -------------------------------------------------------------------------------- /lambda/inline/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion : '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html 5 | InlineLambda: 6 | Type: AWS::Serverless::Function 7 | Properties: 8 | Handler: index.handler 9 | Runtime: python3.12 10 | PackageType: Zip 11 | InlineCode: | 12 | def handler(event, context): 13 | message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) 14 | print("Log this for me") 15 | return { 16 | 'message' : message 17 | } -------------------------------------------------------------------------------- /lambda/layers/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions.049ac6d1-80f3-49c8-ab3d-5350226811be] 4 | codeuri = "/workspace/AWS-Examples/lambda/layers/function" 5 | runtime = "python3.12" 6 | architecture = "x86_64" 7 | handler = "function.handler" 8 | manifest_hash = "" 9 | packagetype = "Zip" 10 | functions = ["InlineLambda"] 11 | 12 | [layer_build_definitions] 13 | -------------------------------------------------------------------------------- /lambda/layers/.aws-sam/build/InlineLambda/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | from faker import Faker 3 | 4 | def handler(event, context): 5 | fake = Faker() 6 | message = 'Hello {}!'.format(fake.name()) 7 | info = { 8 | "Type": "Container Example", 9 | "Version": 1 10 | } 11 | info_json = json.dumps(info) 12 | print(info_json) 13 | return { 14 | 'message' : message 15 | } -------------------------------------------------------------------------------- /lambda/layers/.aws-sam/build/packaged.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Properties: 7 | Handler: function.handler 8 | Runtime: python3.12 9 | PackageType: Zip 10 | CodeUri: s3://my-lambda-artifacts-ab-1512/zip-layer-python/f94a593ddd38e2040eba402bfbc668fc 11 | Layers: 12 | - arn:aws:lambda:ca-central-1:982383527471:layer:faker-py-layer:2 13 | Metadata: 14 | SamResourceId: InlineLambda 15 | -------------------------------------------------------------------------------- /lambda/layers/.aws-sam/build/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Properties: 7 | Handler: function.handler 8 | Runtime: python3.12 9 | PackageType: Zip 10 | CodeUri: InlineLambda 11 | Layers: 12 | - arn:aws:lambda:ca-central-1:982383527471:layer:faker-py-layer:2 13 | Metadata: 14 | SamResourceId: InlineLambda 15 | -------------------------------------------------------------------------------- /lambda/layers/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | python_layer/**/* -------------------------------------------------------------------------------- /lambda/layers/bin/layer: -------------------------------------------------------------------------------- 1 | 2 | aws lambda publish-layer-version \ 3 | --layer-name faker-py-layer \ 4 | --description "Faker Python layer" \ 5 | --license-info "MIT" \ 6 | --content S3Bucket=my-lambda-artifacts-ab-1512,S3Key=faker_layer.zip \ 7 | --compatible-runtimes python3.12 -------------------------------------------------------------------------------- /lambda/layers/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # we need the absolute path because relative path was giving us trouble 5 | root_path=$(realpath .) 6 | 7 | # cfn-lint 8 | # ------------------- 9 | # This will check our cloudformation template to ensure its valid format 10 | echo "== CFN linting..." 11 | cfn-lint "${root_path}/template.yml" -------------------------------------------------------------------------------- /lambda/layers/function/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | from faker import Faker 3 | 4 | def handler(event, context): 5 | fake = Faker() 6 | message = 'Hello {}!'.format(fake.name()) 7 | info = { 8 | "Type": "Container Example", 9 | "Version": 1 10 | } 11 | info_json = json.dumps(info) 12 | print(info_json) 13 | return { 14 | 'message' : message 15 | } -------------------------------------------------------------------------------- /lambda/layers/samconfig.toml: -------------------------------------------------------------------------------- 1 | version=0.1 2 | [default.package.parameters] 3 | s3_bucket = "my-lambda-artifacts-ab-1512" 4 | region = "ca-central-1" 5 | [default.deploy.parameters] 6 | s3_bucket = "my-lambda-artifacts-ab-1512" 7 | region = "ca-central-1" -------------------------------------------------------------------------------- /lambda/layers/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion : '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html 5 | InlineLambda: 6 | Type: AWS::Serverless::Function 7 | Properties: 8 | Handler: function.handler 9 | Runtime: python3.12 10 | PackageType: Zip 11 | CodeUri: "./function/" 12 | Layers: 13 | - arn:aws:lambda:ca-central-1:982383527471:layer:faker-py-layer:2 -------------------------------------------------------------------------------- /lambda/rust/Readme.md: -------------------------------------------------------------------------------- 1 | # Install Runtime for Rust Lambda 2 | 3 | https://github.com/awslabs/aws-lambda-rust-runtime 4 | 5 | brew tap cargo-lambda/cargo-lambda 6 | brew install cargo-lambda 7 | 8 | ## Run 9 | cargo lambda new example 10 | cd example 11 | cargo lambda build --release 12 | 13 | ## Deploy 14 | cargo lambda deploy --iam-role arn:aws:iam::982383527471:role/RustLambdaAll 15 | 16 | ## Invoke 17 | 18 | Install awscurl 19 | 20 | ```sh 21 | pip install awscurl 22 | ``` 23 | 24 | Invoke 25 | ```sh 26 | curl -v 'https://h4upffvrlo4vsifvw5axm7mm640nzpzj.lambda-url.ca-central-1.on.aws/?name=Andrew' \ 27 | -H 'content-type: application/json' 28 | ``` -------------------------------------------------------------------------------- /lambda/rust/example/.gitignore: -------------------------------------------------------------------------------- 1 | /target -------------------------------------------------------------------------------- /lambda/rust/example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "example" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # Starting in Rust 1.62 you can use `cargo add` to add dependencies 7 | # to your project. 8 | # 9 | # If you're using an older Rust version, 10 | # download cargo-edit(https://github.com/killercup/cargo-edit#installation) 11 | # to install the `add` subcommand. 12 | # 13 | # Running `cargo add DEPENDENCY_NAME` will 14 | # add the latest version of a dependency to the list, 15 | # and it will keep the alphabetic ordering for you. 16 | 17 | [dependencies] 18 | lambda_http = "0.10.0" 19 | 20 | tokio = { version = "1", features = ["macros"] } 21 | 22 | -------------------------------------------------------------------------------- /lambda/zip_local/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions.ee2987c4-5d23-44f0-a3dd-35410d8dea63] 4 | codeuri = "/workspace/AWS-Examples/lambda/zip_local/function" 5 | runtime = "python3.12" 6 | architecture = "x86_64" 7 | handler = "index.handler" 8 | manifest_hash = "" 9 | packagetype = "Zip" 10 | functions = ["InlineLambda"] 11 | 12 | [layer_build_definitions] 13 | -------------------------------------------------------------------------------- /lambda/zip_local/.aws-sam/build/InlineLambda/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def handler(event, context): 4 | message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) 5 | info = { 6 | "Type": "Zip Inline", 7 | "Version": 1 8 | } 9 | info_json = json.dumps(info) 10 | print(info_json) 11 | return { 12 | 'message' : message 13 | } -------------------------------------------------------------------------------- /lambda/zip_local/.aws-sam/build/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Properties: 7 | Handler: function.handler 8 | Runtime: python3.12 9 | PackageType: Zip 10 | CodeUri: InlineLambda 11 | Metadata: 12 | SamResourceId: InlineLambda 13 | -------------------------------------------------------------------------------- /lambda/zip_local/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # we need the absolute path because relative path was giving us trouble 5 | root_path=$(realpath .) 6 | 7 | # cfn-lint 8 | # ------------------- 9 | # This will check our cloudformation template to ensure its valid format 10 | echo "== CFN linting..." 11 | cfn-lint "${root_path}/template.yml" -------------------------------------------------------------------------------- /lambda/zip_local/function/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def handler(event, context): 4 | message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) 5 | info = { 6 | "Type": "Zip Inline", 7 | "Version": 1 8 | } 9 | info_json = json.dumps(info) 10 | print(info_json) 11 | return { 12 | 'message' : message 13 | } -------------------------------------------------------------------------------- /lambda/zip_local/samconfig.toml: -------------------------------------------------------------------------------- 1 | version=0.1 2 | [default.deploy.parameters] 3 | s3_bucket = "my-lambda-artifacts-ab-1512" 4 | region = "ca-central-1" -------------------------------------------------------------------------------- /lambda/zip_local/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion : '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html 5 | InlineLambda: 6 | Type: AWS::Serverless::Function 7 | Properties: 8 | Handler: function.handler 9 | Runtime: python3.12 10 | PackageType: Zip 11 | CodeUri: "./function/" -------------------------------------------------------------------------------- /lambda/zip_package/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions.9fe0d902-5c37-4923-8ed6-39fe0ea57187] 4 | codeuri = "/workspace/AWS-Examples/lambda/zip_package/function" 5 | runtime = "python3.12" 6 | architecture = "x86_64" 7 | handler = "function.handler" 8 | manifest_hash = "" 9 | packagetype = "Zip" 10 | functions = ["InlineLambda"] 11 | 12 | [layer_build_definitions] 13 | -------------------------------------------------------------------------------- /lambda/zip_package/.aws-sam/build/InlineLambda/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def handler(event, context): 4 | message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) 5 | info = { 6 | "Type": "Zip Package", 7 | "Version": 1 8 | } 9 | info_json = json.dumps(info) 10 | print(info_json) 11 | return { 12 | 'message' : message 13 | } -------------------------------------------------------------------------------- /lambda/zip_package/.aws-sam/build/packaged.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Properties: 7 | Handler: function.handler 8 | Runtime: python3.12 9 | PackageType: Zip 10 | CodeUri: s3://my-lambda-artifacts-ab-1512/zip-package-python/1168da984ad6d8facd8e4289a6feff90 11 | Metadata: 12 | SamResourceId: InlineLambda 13 | -------------------------------------------------------------------------------- /lambda/zip_package/.aws-sam/build/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | InlineLambda: 5 | Type: AWS::Serverless::Function 6 | Properties: 7 | Handler: function.handler 8 | Runtime: python3.12 9 | PackageType: Zip 10 | CodeUri: InlineLambda 11 | Metadata: 12 | SamResourceId: InlineLambda 13 | -------------------------------------------------------------------------------- /lambda/zip_package/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # we need the absolute path because relative path was giving us trouble 5 | root_path=$(realpath .) 6 | 7 | # cfn-lint 8 | # ------------------- 9 | # This will check our cloudformation template to ensure its valid format 10 | echo "== CFN linting..." 11 | cfn-lint "${root_path}/template.yml" -------------------------------------------------------------------------------- /lambda/zip_package/function/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def handler(event, context): 4 | message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) 5 | info = { 6 | "Type": "Zip Package", 7 | "Version": 1 8 | } 9 | info_json = json.dumps(info) 10 | print(info_json) 11 | return { 12 | 'message' : message 13 | } -------------------------------------------------------------------------------- /lambda/zip_package/samconfig.toml: -------------------------------------------------------------------------------- 1 | version=0.1 2 | [default.package.parameters] 3 | s3_bucket = "my-lambda-artifacts-ab-1512" 4 | region = "ca-central-1" 5 | [default.deploy.parameters] 6 | s3_bucket = "my-lambda-artifacts-ab-1512" 7 | region = "ca-central-1" -------------------------------------------------------------------------------- /lambda/zip_package/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion : '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Resources: 4 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html 5 | InlineLambda: 6 | Type: AWS::Serverless::Function 7 | Properties: 8 | Handler: function.handler 9 | Runtime: python3.12 10 | PackageType: Zip 11 | CodeUri: "./function/" -------------------------------------------------------------------------------- /memorydb/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy ec2 instance to interact with redis" 4 | 5 | STACK_NAME="ec2-4-redis" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /mq/amqp/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'bunny' 7 | gem 'ox' 8 | gem 'pry' -------------------------------------------------------------------------------- /mq/amqp/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | amq-protocol (2.3.2) 5 | bunny (2.22.0) 6 | amq-protocol (~> 2.3, >= 2.3.1) 7 | sorted_set (~> 1, >= 1.0.2) 8 | coderay (1.1.3) 9 | method_source (1.0.0) 10 | ox (2.14.18) 11 | pry (0.14.2) 12 | coderay (~> 1.1) 13 | method_source (~> 1.0) 14 | rbtree (0.4.6) 15 | set (1.1.0) 16 | sorted_set (1.0.3) 17 | rbtree 18 | set (~> 1.0) 19 | 20 | PLATFORMS 21 | ruby 22 | x86_64-linux 23 | 24 | DEPENDENCIES 25 | bunny 26 | ox 27 | pry 28 | 29 | BUNDLED WITH 30 | 2.5.6 31 | -------------------------------------------------------------------------------- /mq/amqp/consumer.rb: -------------------------------------------------------------------------------- 1 | require 'bunny' 2 | 3 | 4 | connection_string = "amqps://admin:Testing123456!@b-7cc94b99-4432-4a9c-ae14-9ab61199a0d7.mq.us-east-1.amazonaws.com:5671" 5 | connection = Bunny.new(connection_string) 6 | connection.start 7 | 8 | channel = connection.create_channel 9 | queue = channel.queue('hello') 10 | begin 11 | queue.subscribe(block: true) do |_delivery_info, _properties, body| 12 | puts body 13 | end 14 | rescue => e 15 | puts e.inspect 16 | channel.close 17 | connection.close 18 | exit(0) 19 | end -------------------------------------------------------------------------------- /mq/amqp/publisher.rb: -------------------------------------------------------------------------------- 1 | require 'bunny' 2 | connection_string = "amqps://admin:Testing123456!@b-7cc94b99-4432-4a9c-ae14-9ab61199a0d7.mq.us-east-1.amazonaws.com:5671" 3 | connection = Bunny.new(connection_string) 4 | connection.start 5 | 6 | 7 | channel = connection.create_channel 8 | queue = channel.queue('hello') 9 | exchange = channel.default_exchange 10 | 11 | 12 | begin 13 | exchange.publish("Hello World!", routing_key: queue.name) 14 | channel.close 15 | connection.close 16 | rescue => e 17 | puts e.inspect 18 | channel.close 19 | connection.close 20 | exit(0) 21 | end -------------------------------------------------------------------------------- /mq/mqtt/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'mqtt' 7 | gem 'ox' 8 | gem 'pry' -------------------------------------------------------------------------------- /mq/mqtt/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | coderay (1.1.3) 5 | method_source (1.0.0) 6 | mqtt (0.6.0) 7 | ox (2.14.18) 8 | pry (0.14.2) 9 | coderay (~> 1.1) 10 | method_source (~> 1.0) 11 | 12 | PLATFORMS 13 | ruby 14 | x86_64-linux 15 | 16 | DEPENDENCIES 17 | mqtt 18 | ox 19 | pry 20 | 21 | BUNDLED WITH 22 | 2.5.6 23 | -------------------------------------------------------------------------------- /mq/mqtt/consumer.rb: -------------------------------------------------------------------------------- 1 | require 'mqtt' 2 | 3 | host = 'mqtts://admin:Testing123456!@b-6b39d23f-d358-4850-bfd4-a7784795fa05-1.mq.us-east-1.amazonaws.com:8883' 4 | topic = 'test/topic' 5 | 6 | begin 7 | MQTT::Client.connect(host) do |client| 8 | client.get(topic) do |topic, message| 9 | puts topic 10 | puts message 11 | end 12 | end 13 | rescue => e 14 | puts e.inspect 15 | end -------------------------------------------------------------------------------- /mq/mqtt/publisher.rb: -------------------------------------------------------------------------------- 1 | require 'mqtt' 2 | 3 | host = 'mqtts://admin:Testing123456!@b-6b39d23f-d358-4850-bfd4-a7784795fa05-1.mq.us-east-1.amazonaws.com:8883' 4 | topic = 'test/topic' 5 | message = "Hello World! MQTT" 6 | 7 | begin 8 | MQTT::Client.connect(host) do |client| 9 | client.publish(topic,message) 10 | end 11 | rescue => e 12 | puts e.inspect 13 | end -------------------------------------------------------------------------------- /mq/stomp/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'stomp' 7 | gem 'ox' 8 | gem 'pry' 9 | -------------------------------------------------------------------------------- /mq/stomp/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | coderay (1.1.3) 5 | method_source (1.0.0) 6 | ox (2.14.18) 7 | pry (0.14.2) 8 | coderay (~> 1.1) 9 | method_source (~> 1.0) 10 | stomp (1.4.10) 11 | 12 | PLATFORMS 13 | ruby 14 | x86_64-linux 15 | 16 | DEPENDENCIES 17 | ox 18 | pry 19 | stomp 20 | 21 | BUNDLED WITH 22 | 2.5.6 23 | -------------------------------------------------------------------------------- /mq/stomp/consumer.rb: -------------------------------------------------------------------------------- 1 | require 'stomp' 2 | 3 | login = 'admin' 4 | passcode = 'Testing123456!' 5 | host = 'b-6b39d23f-d358-4850-bfd4-a7784795fa05-1.mq.us-east-1.amazonaws.com' 6 | port = 61614 7 | 8 | config = { 9 | hosts: [ 10 | login: login, 11 | passcode: passcode, 12 | host: host, 13 | port: port, 14 | ssl: true 15 | ] 16 | } 17 | 18 | #str = 'stomp+ssl://admin:Testing123456!@b-6b39d23f-d358-4850-bfd4-a7784795fa05-1.mq.us-east-1.amazonaws.com:61614' 19 | client = Stomp::Client.new(config) 20 | dest = '/queue/test' 21 | client.subscribe(dest) do |message| 22 | puts 'subbed' 23 | puts message 24 | client.acknowledge(message) 25 | end 26 | client.join -------------------------------------------------------------------------------- /mq/stomp/publisher.rb: -------------------------------------------------------------------------------- 1 | require 'stomp' 2 | 3 | login = 'admin' 4 | passcode = 'Testing123456!' 5 | host = 'b-6b39d23f-d358-4850-bfd4-a7784795fa05-1.mq.us-east-1.amazonaws.com' 6 | port = 61614 7 | 8 | config = { 9 | hosts: [ 10 | login: login, 11 | passcode: passcode, 12 | host: host, 13 | port: port, 14 | ssl: true 15 | ] 16 | } 17 | 18 | #str = 'stomp+ssl://admin:Testing123456!@b-6b39d23f-d358-4850-bfd4-a7784795fa05-1.mq.us-east-1.amazonaws.com:61614' 19 | client = Stomp::Client.new(config) 20 | 21 | dest = '/queue/test' 22 | client.publish(dest,"Hello World! STOMP!") 23 | client.close -------------------------------------------------------------------------------- /opensearch/opensearch/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'opensearch-ruby' 7 | gem 'opensearch-aws-sigv4' 8 | gem 'ox' 9 | gem 'pry' -------------------------------------------------------------------------------- /opensearch/opensearch/Readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/opensearch/opensearch/Readme.md -------------------------------------------------------------------------------- /personalize/main.py: -------------------------------------------------------------------------------- 1 | import boto3 2 | from botocore.config import Config 3 | 4 | my_config = Config( 5 | region_name = 'ca-central-1' 6 | ) 7 | client = boto3.client('personalize-runtime', config=my_config) 8 | 9 | campaign_arn = 'arn:aws:personalize:ca-central-1:982383527471:campaign/my-campaign' 10 | user_id = '127' 11 | item_id='9910' 12 | # context = {'itemId': 'item-id-for-context'} 13 | 14 | resp = client.get_recommendations( 15 | campaignArn=campaign_arn, 16 | userId=user_id, 17 | itemId=item_id, 18 | # context=context 19 | ) 20 | 21 | # Print out the recommendation results 22 | for item in resp['itemList']: 23 | print(f"Item ID: {item['itemId']} Score: {item.get('score', 'N/A')}") -------------------------------------------------------------------------------- /personalize/requirements.txt: -------------------------------------------------------------------------------- 1 | boto3 -------------------------------------------------------------------------------- /polly/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem "aws-sdk-polly" 7 | gem 'pry' 8 | gem 'nokogiri' -------------------------------------------------------------------------------- /polly/main.rb: -------------------------------------------------------------------------------- 1 | require 'aws-sdk-polly' 2 | require 'pry' 3 | 4 | client = Aws::Polly::Client.new 5 | 6 | resp = client.synthesize_speech({ 7 | engine: "standard", 8 | output_format: "mp3", 9 | sample_rate: "8000", 10 | text: "All Gaul is divided into three parts", 11 | text_type: "text", 12 | voice_id: "Joanna", 13 | }) 14 | 15 | File.open('sample.mp3', 'w') do |file| 16 | data = resp.audio_stream.read 17 | file.write data 18 | end -------------------------------------------------------------------------------- /rds/basic/Readme.md: -------------------------------------------------------------------------------- 1 | # Create Secret via Secrets Manager 2 | 3 | ```sh 4 | aws secretsmanager create-secret \ 5 | --name MyRdsPassword \ 6 | --description "My rds password" \ 7 | --secret-string "{\"password\":\"mypassword\"}" 8 | ``` 9 | 10 | -------------------------------------------------------------------------------- /rds/basic/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy rds" 4 | 5 | STACK_NAME="rds-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --parameter-overrides VpcId="vpc-08f0ec02f7471b018" WebServerSGGroupId="sg-098fa834d80e2fc3c" RdsSecretArn="arn:aws:secretsmanager:ca-central-1:982383527471:secret:MyRdsPassword-x51sy9" Username="andrewbrown" Subnets="subnet-0e0fd31733061237d,subnet-0377c6b172e2951d4,subnet-0d8058cb02f147a86" \ 13 | --region ca-central-1 \ 14 | --stack-name $STACK_NAME 15 | -------------------------------------------------------------------------------- /rds/pgvector/Readme.md: -------------------------------------------------------------------------------- 1 | ```sql 2 | SELECT * FROM pg_available_extensions WHERE name = 'vector'; 3 | ``` 4 | 5 | ```sql 6 | CREATE EXTENSION IF NOT EXISTS vector; 7 | ``` 8 | 9 | ```sql 10 | CREATE TABLE items ( 11 | id SERIAL PRIMARY KEY, 12 | embedding vector(3) -- a vector of dimension 3 13 | ); 14 | ``` 15 | 16 | ```sql 17 | INSERT INTO items (embedding) VALUES 18 | ('[0.1, 0.2, 0.3]'), 19 | ('[0.4, 0.5, 0.6]'), 20 | ('[0.7, 0.8, 0.9]'); 21 | ``` 22 | 23 | ```sql 24 | SELECT * FROM items; 25 | ``` 26 | 27 | Nearest Neighbor Search 28 | 29 | ```sql 30 | SELECT id, embedding, embedding <-> '[0.2, 0.1, 0.4]' AS distance 31 | FROM items 32 | ORDER BY embedding <-> '[0.2, 0.1, 0.4]' LIMIT 5; 33 | ``` -------------------------------------------------------------------------------- /rekognition/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'aws-sdk-rekognition' 7 | gem 'ox' 8 | gem 'pry' -------------------------------------------------------------------------------- /rekognition/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Create bucket and upload file 3 | 4 | ```sh 5 | aws s3 mb s3://rekog-example-1422 --region us-east-1 6 | aws s3 cp andrew.jpg s3://rekog-example-1422 7 | ``` 8 | 9 | # Run ruby code 10 | 11 | ```sh 12 | bundle install 13 | bundle exec ruby main.rb 14 | ``` -------------------------------------------------------------------------------- /rekognition/andrew.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/rekognition/andrew.jpg -------------------------------------------------------------------------------- /route53/alias/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy route53 alias" 4 | 5 | STACK_NAME="route53-alias" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region us-east-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /route53/basic/Readme.md: -------------------------------------------------------------------------------- 1 | # Change Record Set 2 | 3 | aws route53 change-resource-record-sets \ 4 | --hosted-zone-id Z09877273W35UBRD4GPTY \ 5 | --region us-east-1 \ 6 | --change-batch ' 7 | { 8 | "Changes": [ 9 | { 10 | "Action": "UPSERT", 11 | "ResourceRecordSet": { 12 | "Name": "www.cloudborg.org", 13 | "Type": "A", 14 | "TTL": 300, 15 | "ResourceRecords": [{ "Value": "50.17.101.87" }] 16 | } 17 | } 18 | ] 19 | }' 20 | 21 | # References 22 | 23 | https://awscli.amazonaws.com/v2/documentation/api/latest/reference/route53/change-resource-record-sets.html#examples -------------------------------------------------------------------------------- /route53/basic/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy route53 servers" 4 | 5 | STACK_NAME="aws-route53-servers" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --parameter-overrides ServerName="Server 1" \ 12 | --no-execute-changeset \ 13 | --region us-east-1 \ 14 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /s3/acls/policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Grants": [ 3 | { 4 | "Grantee": { 5 | "DisplayName": "andrewbrown", 6 | "ID": "e602ac4aeb23a4d25642f95dc2fbc085279cf5b30824067afbb329d7eeb49fe5", 7 | "Type": "CanonicalUser" 8 | }, 9 | "Permission": "FULL_CONTROL" 10 | } 11 | ], 12 | "Owner": { 13 | "DisplayName": "andrewbrown", 14 | "ID": "74ababf54b6810c1d34431ceee560f5de666617490e539850338964d29c30eef" 15 | } 16 | } -------------------------------------------------------------------------------- /s3/acls/policy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 74ababf54b6810c1d34431ceee560f5de666617490e539850338964d29c30eef 5 | andrewbrown 6 | 7 | 8 | 9 | 11 | e602ac4aeb23a4d25642f95dc2fbc085279cf5b30824067afbb329d7eeb49fe5 12 | andrewbrown 13 | 14 | FULL_CONTROL 15 | 16 | 17 | -------------------------------------------------------------------------------- /s3/bash-scripts/create-bucket: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== create bucket" 3 | 4 | # Check for bucket name 5 | if [ -z "$1" ]; then 6 | echo "There needs to be a bucket name eg. ./bucket my-bucket-name" 7 | exit 1 8 | fi 9 | 10 | BUCKET_NAME=$1 11 | 12 | # https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html 13 | aws s3api create-bucket \ 14 | --bucket $BUCKET_NAME \ 15 | --create-bucket-configuration="LocationConstraint=ca-central-1" \ 16 | --query Location \ 17 | --output text -------------------------------------------------------------------------------- /s3/bash-scripts/delete-bucket: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== delete bucket" 3 | 4 | # Check for bucket name 5 | if [ -z "$1" ]; then 6 | echo "There needs to be a bucket name eg. ./bucket my-bucket-name" 7 | exit 1 8 | fi 9 | 10 | BUCKET_NAME=$1 11 | 12 | # https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html 13 | aws s3api delete-bucket \ 14 | --bucket $BUCKET_NAME -------------------------------------------------------------------------------- /s3/bash-scripts/delete-objects: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== delete-objects" 3 | 4 | # Exit immediately if any command returns a non-zero status 5 | set -e 6 | 7 | # Check for bucket name 8 | if [ -z "$1" ]; then 9 | echo "There needs to be a bucket name eg. ./bucket my-bucket-name" 10 | exit 1 11 | fi 12 | 13 | BUCKET_NAME=$1 14 | 15 | aws s3api list-objects-v2 \ 16 | --bucket $BUCKET_NAME \ 17 | --query Contents[].Key \ 18 | | jq -n '{Objects: [inputs | .[] | {Key: .}]}' > /tmp/delete_objects.json 19 | 20 | aws s3api delete-objects --bucket $BUCKET_NAME --delete file:///tmp/delete_objects.json 21 | -------------------------------------------------------------------------------- /s3/bash-scripts/get-newest-bucket: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | aws s3api list-buckets | jq -r '.Buckets | sort_by(.CreationDate) | reverse | .[0] | .Name' -------------------------------------------------------------------------------- /s3/bash-scripts/list-buckets: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== list newest buckets" 3 | 4 | aws s3api list-buckets | jq -r '.Buckets | sort_by(.CreationDate) | reverse | .[0:5] | .[] | .Name' 5 | echo "..." -------------------------------------------------------------------------------- /s3/bash-scripts/list-objects: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== list objects" 3 | 4 | # Check for bucket name 5 | if [ -z "$1" ]; then 6 | echo "There needs to be a bucket name eg. ./bucket my-bucket-name" 7 | exit 1 8 | fi 9 | 10 | BUCKET_NAME=$1 11 | 12 | # https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html 13 | aws s3api list-objects-v2 \ 14 | --bucket $BUCKET_NAME -------------------------------------------------------------------------------- /s3/bash-scripts/put-object: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== put-object" 3 | 4 | # Check for bucket name 5 | if [ -z "$1" ]; then 6 | echo "There needs to be a bucket name eg. ./bucket my-bucket-name" 7 | exit 1 8 | fi 9 | 10 | if [ -z "$2" ]; then 11 | echo "There needs to be a filename eg. ./bucket my-bucket-name filename" 12 | exit 1 13 | fi 14 | BUCKET_NAME=$1 15 | FILENAME=$2 16 | 17 | OBJECT_KEY=$(basename "$FILENAME") 18 | 19 | aws s3api put-object \ 20 | --bucket $BUCKET_NAME \ 21 | --body $FILENAME \ 22 | --key $OBJECT_KEY -------------------------------------------------------------------------------- /s3/batch-operations/.gitignore: -------------------------------------------------------------------------------- 1 | files/file_* -------------------------------------------------------------------------------- /s3/batch-operations/bin/create_files: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Directory where the files will be created 4 | DIR="/workspace/AWS-Examples/s3/batch-operations/files" 5 | 6 | # Create directory if it does not exist 7 | mkdir -p $DIR 8 | 9 | # Loop to create 20 files 10 | for i in {1..20}; do 11 | # Generate a random size between 1 and 1000 bytes 12 | SIZE=$((RANDOM % 1000 + 1)) 13 | 14 | # Create a file with the determined size 15 | dd if=/dev/zero of="${DIR}/file_$i" bs=1 count=$SIZE 2>/dev/null 16 | done 17 | 18 | echo "20 files created in $DIR" -------------------------------------------------------------------------------- /s3/batch-operations/files/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/batch-operations/files/.keep -------------------------------------------------------------------------------- /s3/batch-operations/files/manifest.csv: -------------------------------------------------------------------------------- 1 | batch-fun-ab6347,file_1 2 | batch-fun-ab6347,file_2 3 | batch-fun-ab6347,file_3 4 | batch-fun-ab6347,file_4 5 | batch-fun-ab6347,file_5 6 | batch-fun-ab6347,file_6 7 | batch-fun-ab6347,file_7 8 | batch-fun-ab6347,file_8 9 | batch-fun-ab6347,file_9 10 | batch-fun-ab6347,file_19 11 | batch-fun-ab6347,file_11 12 | batch-fun-ab6347,file_12 13 | batch-fun-ab6347,file_13 14 | batch-fun-ab6347,file_14 15 | batch-fun-ab6347,file_15 16 | batch-fun-ab6347,file_16 17 | batch-fun-ab6347,file_17 18 | batch-fun-ab6347,file_18 19 | batch-fun-ab6347,file_19 20 | batch-fun-ab6347,file_20 21 | -------------------------------------------------------------------------------- /s3/bucket-policy/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket 2 | 3 | aws s3 mb s3://bucket-policy-example-ab-5235 4 | 5 | ## Create bucket policy 6 | 7 | aws s3api put-bucket-policy --bucket bucket-policy-example-ab-5235 --policy file://policy.json 8 | 9 | # In the other account access the bucket 10 | 11 | touch bootcamp.txt 12 | aws s3 cp bootcamp.txt s3://bucket-policy-example-ab-5235 13 | aws s3 ls s3://bucket-policy-example-ab-5235 14 | 15 | 16 | ## Cleanup 17 | 18 | aws s3 rm s3://bucket-policy-example-ab-5235/bootcamp.txt 19 | aws s3 rb s3://bucket-policy-example-ab-5235 -------------------------------------------------------------------------------- /s3/bucket-policy/policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Statement": [ 3 | { 4 | "Effect": "Allow", 5 | "Principal": { 6 | "AWS": "arn:aws:iam::387543059434:user/andrewbrown" 7 | }, 8 | "Action": [ 9 | "s3:ListBucket", 10 | "s3:GetObject", 11 | "s3:PutObject" 12 | ], 13 | "Resource": [ 14 | "arn:aws:s3:::bucket-policy-example-ab-5235", 15 | "arn:aws:s3:::bucket-policy-example-ab-5235/*" 16 | ] 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /s3/byte-range/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket 2 | 3 | aws s3 mb s3://range-run-ab-53252 4 | 5 | ## Upload our file 6 | 7 | aws s3api put-object --bucket range-run-ab-53252 --key hello.txt --body hello.txt 8 | 9 | ## Get an Object range of bytes 10 | 11 | ### Get only the word hello 12 | aws s3api get-object --bucket range-run-ab-53252 --key hello.txt --range bytes=0-4 range.txt 13 | 14 | ### Get only the word world 15 | 16 | aws s3api get-object --bucket range-run-ab-53252 --key hello.txt --range bytes=6-10 range.txt 17 | 18 | ## Cleanup 19 | 20 | aws s3 rm s3://range-run-ab-53252/hello.txt 21 | aws s3 rb s3://range-run-ab-53252 -------------------------------------------------------------------------------- /s3/byte-range/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World -------------------------------------------------------------------------------- /s3/byte-range/range.txt: -------------------------------------------------------------------------------- 1 | Hello -------------------------------------------------------------------------------- /s3/change-storage-class/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket 2 | 3 | aws s3 mb s3://class-fun-ab-6346 4 | 5 | ## Create a file 6 | 7 | echo "Hello World" > hello.txt 8 | aws s3 cp hello.txt s3://class-fun-ab-6346 --storage-class STANDARD_IA 9 | 10 | ## Cleanup 11 | 12 | aws s3 rm s3://class-fun-ab-6346/hello.txt 13 | aws s3 rb s3://class-fun-ab-6346 -------------------------------------------------------------------------------- /s3/change-storage-class/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /s3/checksums/myfile.txt: -------------------------------------------------------------------------------- 1 | Hello Mars 2 | -------------------------------------------------------------------------------- /s3/checksums/sha1_checksum.rb: -------------------------------------------------------------------------------- 1 | require "digest" 2 | require "base64" 3 | checksum = Digest::SHA1.file("myfile.txt").to_s 4 | enc = Base64.encode64(checksum).force_encoding('UTF-8') 5 | puts enc -------------------------------------------------------------------------------- /s3/cors/bucket-policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Sid": "PublicReadGetObject", 6 | "Effect": "Allow", 7 | "Principal": "*", 8 | "Action": [ 9 | "s3:GetObject" 10 | ], 11 | "Resource": [ 12 | "arn:aws:s3:::cors-fun-ab-36252/*" 13 | ] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /s3/cors/bucket-policy2.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Sid": "PublicReadGetObject", 6 | "Effect": "Allow", 7 | "Principal": "*", 8 | "Action": [ 9 | "s3:GetObject" 10 | ], 11 | "Resource": [ 12 | "arn:aws:s3:::cors-fun2-ab-36252/*" 13 | ] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /s3/cors/cors.json: -------------------------------------------------------------------------------- 1 | { 2 | "CORSRules": [ 3 | { 4 | "AllowedOrigins": ["https://1kccnjkm43.execute-api.ca-central-1.amazonaws.com"], 5 | "AllowedHeaders": ["*"], 6 | "AllowedMethods": ["PUT", "POST", "DELETE"], 7 | "MaxAgeSeconds": 3000, 8 | "ExposeHeaders": ["x-amz-server-side-encryption"] 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /s3/cors/hello.js: -------------------------------------------------------------------------------- 1 | console.log('hello world') -------------------------------------------------------------------------------- /s3/cors/website.json: -------------------------------------------------------------------------------- 1 | { 2 | "IndexDocument": { 3 | "Suffix": "index.html" 4 | }, 5 | "ErrorDocument": { 6 | "Key": "error.html" 7 | } 8 | } -------------------------------------------------------------------------------- /s3/dual-endpoints/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | ## Create a bucket 3 | 4 | ```sh 5 | aws s3 mb s3://endpoint-test-ab-5153 6 | ``` 7 | 8 | ## Upload a file to s3 using standard endpoint 9 | 10 | ```sh 11 | touch standard.txt 12 | aws s3 cp standard.txt s3://endpoint-test-ab-5153 --endpoint-url https://s3.ca-central-1.amazonaws.com 13 | ``` 14 | 15 | ## Upload a file to s3 using dualstack endpoint 16 | 17 | ```sh 18 | touch dualstack.txt 19 | aws s3 cp dualstack.txt s3://endpoint-test-ab-5153 --endpoint-url https://s3.dualstack.ca-central-1.amazonaws.com 20 | ``` 21 | 22 | ## Cleanup 23 | 24 | ```sh 25 | aws s3 rm s3://endpoint-test-ab-5153/standard.txt 26 | aws s3 rm s3://endpoint-test-ab-5153/dualstack.txt 27 | aws s3 rb s3://endpoint-test-ab-5153 28 | ``` -------------------------------------------------------------------------------- /s3/dual-endpoints/dualstack.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/dual-endpoints/dualstack.txt -------------------------------------------------------------------------------- /s3/dual-endpoints/standard.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/dual-endpoints/standard.txt -------------------------------------------------------------------------------- /s3/encryption-client/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'aws-sdk-s3' 7 | gem 'ox' 8 | gem 'pry' -------------------------------------------------------------------------------- /s3/encryption-client/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket 2 | 3 | aws s3 mb s3://encrypt-client-fun-ab-634232 4 | 5 | 6 | ### Run our our SDK ruby script 7 | 8 | bundle exec ruby encrypt.rb 9 | 10 | 11 | # Cleanup 12 | 13 | aws s3 rm s3://encrypt-client-fun-ab-634232/hello.txt 14 | aws s3 rb s3://encrypt-client-fun-ab-634232 15 | -------------------------------------------------------------------------------- /s3/encryption/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /s3/encryption/ssec.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/encryption/ssec.key -------------------------------------------------------------------------------- /s3/etags/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | aws = { 4 | source = "hashicorp/aws" 5 | version = "5.30.0" 6 | } 7 | } 8 | } 9 | 10 | provider "aws" { 11 | # Configuration options 12 | } 13 | 14 | resource "aws_s3_bucket" "default" { 15 | } 16 | 17 | resource "aws_s3_object" "object" { 18 | bucket = aws_s3_bucket.default.id 19 | key = "myfile.txt" 20 | source = "myfile.txt" 21 | 22 | etag = filemd5("myfile.txt") 23 | } -------------------------------------------------------------------------------- /s3/etags/myfile.txt: -------------------------------------------------------------------------------- 1 | Hello Jupiter! -------------------------------------------------------------------------------- /s3/event-notifications/.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | tmp/*.json -------------------------------------------------------------------------------- /s3/event-notifications/bin/function: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | WORKPATH="/workspace/AWS-Examples/s3/event-notifications" 4 | BUCKET=$(terraform output -raw s3_bucket_name) 5 | 6 | aws s3 rm "s3://$BUCKET/function/function.json" 7 | aws s3 cp "$WORKPATH/tmp/function.json" "s3://$BUCKET/function/function.json" -------------------------------------------------------------------------------- /s3/event-notifications/bin/queue: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | WORKPATH="/workspace/AWS-Examples/s3/event-notifications" 4 | BUCKET="$(terraform output -raw s3_bucket_name)" 5 | 6 | aws s3 rm "s3://$BUCKET/queue/queue.json" 7 | aws s3 cp "$WORKPATH/tmp/queue.json" "s3://$BUCKET/queue/queue.json" -------------------------------------------------------------------------------- /s3/event-notifications/bin/test_server: -------------------------------------------------------------------------------- 1 | URL="https://4567-$GITPOD_WORKSPACE_ID.$GITPOD_WORKSPACE_CLUSTER_HOST/data" 2 | 3 | curl -X POST $URL \ 4 | -H "Content-Type: application/json" \ 5 | -d '{"key1": "value1", "key2": "value2"}' -------------------------------------------------------------------------------- /s3/event-notifications/bin/topic: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | WORKPATH="/workspace/AWS-Examples/s3/event-notifications" 4 | BUCKET="$(terraform output -raw s3_bucket_name)" 5 | 6 | aws s3 rm "s3://$BUCKET/topic/topic.json" 7 | aws s3 cp "$WORKPATH/tmp/topic.json" "s3://$BUCKET/topic/topic.json" -------------------------------------------------------------------------------- /s3/event-notifications/code/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | gem 'aws-sdk-sqs' 6 | gem 'aws-sdk-s3' 7 | gem 'aws-sdk-sns' 8 | gem 'pry' 9 | gem 'nokogiri' 10 | gem 'sinatra' 11 | gem 'puma' -------------------------------------------------------------------------------- /s3/event-notifications/function/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def lambda_handler(event, context): 4 | print("<>HELLO!<>") 5 | # Print the string representation of the event data 6 | print("Received event: " + json.dumps(event, indent=2)) 7 | 8 | # You can process the event data as needed here 9 | 10 | return { 11 | 'statusCode': 200, 12 | 'body': json.dumps('Event processed') 13 | } -------------------------------------------------------------------------------- /s3/event-notifications/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | aws = { 4 | source = "hashicorp/aws" 5 | version = "5.31.0" 6 | } 7 | } 8 | } 9 | 10 | provider "aws" { 11 | # Configuration options 12 | } -------------------------------------------------------------------------------- /s3/event-notifications/queue.tf: -------------------------------------------------------------------------------- 1 | resource "aws_sqs_queue" "queue" { 2 | name = "s3-eve-queue" 3 | policy = data.aws_iam_policy_document.queue.json 4 | } 5 | 6 | 7 | data "aws_iam_policy_document" "queue" { 8 | statement { 9 | effect = "Allow" 10 | 11 | principals { 12 | type = "*" 13 | identifiers = ["*"] 14 | } 15 | 16 | actions = ["sqs:SendMessage"] 17 | resources = ["arn:aws:sqs:*:*:s3-eve-queue"] 18 | 19 | condition { 20 | test = "ArnEquals" 21 | variable = "aws:SourceArn" 22 | values = [aws_s3_bucket.default.arn] 23 | } 24 | } 25 | } 26 | output "queue_url" { 27 | value = aws_sqs_queue.queue.id 28 | } -------------------------------------------------------------------------------- /s3/glacier/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket with an S3 Glacier file 2 | 3 | aws s3 mb s3://s3-glacier-fun-ab-1512 4 | 5 | echo "Hello World" > hello.txt 6 | aws s3 cp hello.txt s3://s3-glacier-fun-ab-1512 --storage-class GLACIER 7 | 8 | ## Copy the file 9 | 10 | 11 | aws s3 cp s3://s3-glacier-fun-ab-1512/hello.txt hello.txt 12 | 13 | > This should fail because you have to restore the object 14 | 15 | ## Restore the Object 16 | 17 | aws s3api restore-object \ 18 | --bucket s3-glacier-fun-ab-1512 \ 19 | --key hello.txt \ 20 | --restore-request Days=1 -------------------------------------------------------------------------------- /s3/glacier/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /s3/iac/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /s3/iac/cdk/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /s3/iac/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project 2 | 3 | You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`CdkStack`) 4 | which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic. 5 | 6 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 7 | 8 | ## Useful commands 9 | 10 | * `npm run build` compile typescript to js 11 | * `npm run watch` watch for changes and compile 12 | * `npm run test` perform the jest unit tests 13 | * `cdk deploy` deploy this stack to your default AWS account/region 14 | * `cdk diff` compare deployed stack with current state 15 | * `cdk synth` emits the synthesized CloudFormation template 16 | -------------------------------------------------------------------------------- /s3/iac/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import * as cdk from 'aws-cdk-lib'; 3 | import { CdkStack } from '../lib/cdk-stack'; 4 | 5 | const app = new cdk.App(); 6 | new CdkStack(app, 'CdkStack'); 7 | -------------------------------------------------------------------------------- /s3/iac/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /s3/iac/cdk/lib/cdk-stack.ts: -------------------------------------------------------------------------------- 1 | import { Stack, StackProps } from 'aws-cdk-lib'; 2 | import * as s3 from 'aws-cdk-lib/aws-s3'; 3 | import { Construct } from 'constructs'; 4 | 5 | export class CdkStack extends Stack { 6 | constructor(scope: Construct, id: string, props?: StackProps) { 7 | super(scope, id, props); 8 | const bucket = new s3.Bucket(this, 'MyBucket'); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /s3/iac/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk", 3 | "version": "0.1.0", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/jest": "^29.5.8", 15 | "@types/node": "20.9.0", 16 | "jest": "^29.7.0", 17 | "ts-jest": "^29.1.1", 18 | "aws-cdk": "2.110.1", 19 | "ts-node": "^10.9.1", 20 | "typescript": "~5.2.2" 21 | }, 22 | "dependencies": { 23 | "aws-cdk-lib": "2.110.1", 24 | "constructs": "^10.0.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /s3/iac/cdk/test/cdk.test.ts: -------------------------------------------------------------------------------- 1 | import * as cdk from 'aws-cdk-lib'; 2 | import { Template, Match } from 'aws-cdk-lib/assertions'; 3 | import * as Cdk from '../lib/cdk-stack'; 4 | 5 | test('SQS Queue and SNS Topic Created', () => { 6 | const app = new cdk.App(); 7 | // WHEN 8 | const stack = new Cdk.CdkStack(app, 'MyTestStack'); 9 | // THEN 10 | 11 | const template = Template.fromStack(stack); 12 | 13 | template.hasResourceProperties('AWS::SQS::Queue', { 14 | VisibilityTimeout: 300 15 | }); 16 | template.resourceCountIs('AWS::SNS::Topic', 1); 17 | }); 18 | -------------------------------------------------------------------------------- /s3/iac/cfn/delete-stack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== delete stack for s3 bucket via CFN" 4 | 5 | STACK_NAME="cfn-s3-simple" 6 | 7 | aws cloudformation delete-stack \ 8 | --stack-name $STACK_NAME \ 9 | --region us-west-2 -------------------------------------------------------------------------------- /s3/iac/cfn/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy s3 bucket via CFN" 4 | 5 | STACK_NAME="cfn-s3-simple" 6 | 7 | aws cloudformation deploy \ 8 | --template-file template.yaml \ 9 | --no-execute-changeset \ 10 | --region us-west-2 \ 11 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /s3/iac/cfn/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: "2010-09-09" 2 | Description: A simple s3 bucket 3 | Resources: 4 | S3Bucket: 5 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-s3-bucket.html 6 | Type: 'AWS::S3::Bucket' 7 | # We don't need supply a Bucket Name as AWS will generate a random name for us. -------------------------------------------------------------------------------- /s3/iac/terraform/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | aws = { 4 | source = "hashicorp/aws" 5 | version = "5.26.0" 6 | } 7 | } 8 | } 9 | 10 | provider "aws" { 11 | # Configuration options 12 | } -------------------------------------------------------------------------------- /s3/iac/terraform/s3.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "my-s3-bucket" { 2 | tags = { 3 | Name = "My bucket" 4 | Environment = "Dev" 5 | } 6 | } -------------------------------------------------------------------------------- /s3/lifecycle/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a new bucket 2 | 3 | aws s3 mb s3://lifecycle-fun-ab-5424453 4 | 5 | # Create lifecycle policy configuration 6 | 7 | aws s3api put-bucket-lifecycle-configuration --bucket lifecycle-fun-ab-5424453 --lifecycle-configuration file://lifecycle.json 8 | 9 | ## Cleanup 10 | 11 | aws s3 rb s3://lifecycle-fun-ab-5424453 -------------------------------------------------------------------------------- /s3/lifecycle/lifecycle.json: -------------------------------------------------------------------------------- 1 | { 2 | "Rules": [ 3 | { 4 | "ID": "Move to IA", 5 | "Status": "Enabled", 6 | "Prefix": "" , 7 | "Transitions": [ 8 | { 9 | "Days": 30, 10 | "StorageClass": "STANDARD_IA" 11 | } 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /s3/metadata/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket 2 | 3 | aws s3 mb s3://metadata-fun-ab-12421 4 | 5 | ### Create a new file 6 | 7 | echo "Hello Mars" > hello.txt 8 | 9 | ## Upload file with metadata 10 | 11 | aws s3api put-object --bucket metadata-fun-ab-12421 --key hello.txt --body hello.txt --metadata Planet=Mars 12 | 13 | ## Get Metadata through head object 14 | 15 | aws s3api head-object --bucket metadata-fun-ab-12421 --key hello.txt 16 | 17 | ## Cleanup 18 | 19 | aws s3 rm s3://metadata-fun-ab-12421/hello.txt 20 | aws s3 rb s3://metadata-fun-ab-12421 -------------------------------------------------------------------------------- /s3/metadata/hello.txt: -------------------------------------------------------------------------------- 1 | Hello Mars 2 | -------------------------------------------------------------------------------- /s3/multipart-upload/.gitignore: -------------------------------------------------------------------------------- 1 | largefile.txt 2 | part-* -------------------------------------------------------------------------------- /s3/multipart-upload/parts.json: -------------------------------------------------------------------------------- 1 | {"Parts": [ 2 | {"PartNumber": 1,"ETag": "f1c9645dbc14efddc7d8a322685f26eb"}, 3 | {"PartNumber": 2,"ETag": "f1c9645dbc14efddc7d8a322685f26eb"}, 4 | {"PartNumber": 3,"ETag": "f1c9645dbc14efddc7d8a322685f26eb"}, 5 | {"PartNumber": 4,"ETag": "f1c9645dbc14efddc7d8a322685f26eb"}, 6 | {"PartNumber": 5,"ETag": "f1c9645dbc14efddc7d8a322685f26eb"} 7 | ]} -------------------------------------------------------------------------------- /s3/object-locks/compliance.txt: -------------------------------------------------------------------------------- 1 | We are the borg -------------------------------------------------------------------------------- /s3/object-locks/default.json: -------------------------------------------------------------------------------- 1 | { "ObjectLockEnabled": "Enabled", "Rule": { "DefaultRetention": { "Mode": "GOVERANCE", "Days": 1 }}} -------------------------------------------------------------------------------- /s3/object-locks/gov.txt: -------------------------------------------------------------------------------- 1 | This is the gov2 2 | -------------------------------------------------------------------------------- /s3/object-locks/legal.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/object-locks/legal.txt -------------------------------------------------------------------------------- /s3/object-tags/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket 2 | 3 | aws s3 mb s3://object-tags-fun-ab-524353 4 | 5 | ## Upload file 6 | 7 | echo "Hello World" > hello.txt 8 | aws s3 cp hello.txt s3://object-tags-fun-ab-524353/hello.txt 9 | 10 | ## Apply Object Tagging 11 | 12 | aws s3api put-object-tagging \ 13 | --bucket object-tags-fun-ab-524353 \ 14 | --key hello.txt \ 15 | --tagging '{"TagSet": [{ "Key": "hello", "Value": "world" }]}' 16 | 17 | 18 | ## Cleanup 19 | 20 | aws s3 rm s3://object-tags-fun-ab-524353/hello.txt 21 | aws s3 rb s3://object-tags-fun-ab-524353 -------------------------------------------------------------------------------- /s3/object-tags/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /s3/prefixes/hello.txt: -------------------------------------------------------------------------------- 1 | Hi there! -------------------------------------------------------------------------------- /s3/replication/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /s3/replication/replication.json: -------------------------------------------------------------------------------- 1 | { 2 | "Role": "arn:aws:iam::982383527471:role/s3-replication-role", 3 | "Rules": [ 4 | { 5 | "Status": "Enabled", 6 | "Priority": 1, 7 | "DeleteMarkerReplication": { "Status": "Disabled" }, 8 | "Filter" : { "Prefix": ""}, 9 | "Destination": { 10 | "Bucket": "arn:aws:s3:::replication-fun-us-east-ab-4535" 11 | } 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /s3/replication/trust.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Effect": "Allow", 6 | "Principal": { 7 | "Service": "s3.amazonaws.com" 8 | }, 9 | "Action": "sts:AssumeRole" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /s3/s3-select/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'aws-sdk-s3' 7 | gem 'pry' 8 | gem 'nokogiri' -------------------------------------------------------------------------------- /s3/s3-select/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create a bucket 2 | 3 | aws s3 mb s3://s3-select-fun-ab-35252 4 | 5 | ## Create a file with data in it 6 | 7 | aws s3 cp /workspace/AWS-Examples/s3/s3-select/top_20_animes.csv s3://s3-select-fun-ab-35252/top_20_animes.csv -------------------------------------------------------------------------------- /s3/sdk/java/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Create a new Maven Project 3 | ```sh 4 | mvn archetype:generate \ 5 | -DgroupId=com.mycompany.app \ 6 | -DartifactId=my-app \ 7 | -DarchetypeArtifactId=maven-archetype-quickstart \ 8 | -DarchetypeVersion=1.4 \ 9 | -DinteractiveMode=false 10 | ``` 11 | 12 | ``` 13 | mvn -B archetype:generate \ 14 | -DarchetypeGroupId=software.amazon.awssdk \ 15 | -DarchetypeArtifactId=archetype-lambda -Dservice=s3 -Dregion=US_EAST_1 \ 16 | -DarchetypeVersion=2.21.29 \ 17 | -DgroupId=com.example.myapp \ 18 | -DartifactId=myapp 19 | ``` -------------------------------------------------------------------------------- /s3/sdk/java/myapp/src/test/java/com/example/myapp/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.example.myapp; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | public class AppTest { 8 | 9 | @Test 10 | public void handleRequest_shouldReturnConstantValue() { 11 | App function = new App(); 12 | Object result = function.handleRequest("echo", null); 13 | assertEquals("echo", result); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /s3/sdk/java/myapp/target/classes/com/example/myapp/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/sdk/java/myapp/target/classes/com/example/myapp/App.class -------------------------------------------------------------------------------- /s3/sdk/java/myapp/target/classes/com/example/myapp/DependencyFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/sdk/java/myapp/target/classes/com/example/myapp/DependencyFactory.class -------------------------------------------------------------------------------- /s3/sdk/java/myapp/target/test-classes/com/example/myapp/AppTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/sdk/java/myapp/target/test-classes/com/example/myapp/AppTest.class -------------------------------------------------------------------------------- /s3/sdk/ruby/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | gem 'aws-sdk-s3' 6 | gem 'pry' 7 | gem 'nokogiri' -------------------------------------------------------------------------------- /s3/server-logs/.gitignore: -------------------------------------------------------------------------------- 1 | Logs/* -------------------------------------------------------------------------------- /s3/server-logs/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /s3/server-logs/hello_mars.txt: -------------------------------------------------------------------------------- 1 | Hello Mars 2 | -------------------------------------------------------------------------------- /s3/server-logs/hello_moon.txt: -------------------------------------------------------------------------------- 1 | Hello Moon 2 | -------------------------------------------------------------------------------- /s3/server-logs/logging.json: -------------------------------------------------------------------------------- 1 | { 2 | "LoggingEnabled": { 3 | "TargetBucket": "server-logs-dest-ab-4242", 4 | "TargetPrefix": "Logs/" 5 | } 6 | } -------------------------------------------------------------------------------- /s3/server-logs/policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Sid": "S3ServerAccessLogsPolicy", 6 | "Effect": "Allow", 7 | "Principal": {"Service": "logging.s3.amazonaws.com"}, 8 | "Action": "s3:PutObject", 9 | "Resource": "arn:aws:s3:::server-logs-dest-ab-4242/Logs/*", 10 | "Condition": { 11 | "ArnLike": {"aws:SourceARN": "arn:aws:s3:::server-logs-source-ab-4242"}, 12 | "StringEquals": {"aws:SourceAccount": "982383527471"} 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /s3/static-website-hosting/app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /s3/static-website-hosting/app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/static-website-hosting/app/public/favicon.ico -------------------------------------------------------------------------------- /s3/static-website-hosting/app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/static-website-hosting/app/public/logo192.png -------------------------------------------------------------------------------- /s3/static-website-hosting/app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/s3/static-website-hosting/app/public/logo512.png -------------------------------------------------------------------------------- /s3/static-website-hosting/app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /s3/static-website-hosting/app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/AboutPage.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function AboutPage() { 4 | return ( 5 |
6 |

About Page

7 |

Welcome to our about page!

8 |
9 | ); 10 | } 11 | 12 | export default AboutPage; -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/ContactPage.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function ContactPage() { 4 | return ( 5 |
6 |

Contact Page

7 |

Welcome to our contact page!

8 |
9 | ); 10 | } 11 | 12 | export default ContactPage; -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/HomePage.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function HomePage() { 4 | return ( 5 |
6 |

Home Page

7 |

Welcome to our home page!

8 |
9 | ); 10 | } 11 | 12 | export default HomePage; -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | 11 | 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /s3/static-website-hosting/app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /s3/static-website-hosting/bin/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy" 4 | 5 | aws cloudformation deploy \ 6 | --template-file /workspace/AWS-Examples/s3/static-website-hosting/template.yaml \ 7 | --stack-name spa-s3 \ 8 | --no-execute-changeset -------------------------------------------------------------------------------- /s3/static-website-hosting/bin/sync: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | aws s3 sync /workspace/AWS-Examples/s3/static-website-hosting/app/build/ s3://www.mindmazelab.com -------------------------------------------------------------------------------- /secrets-manager/basic/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'aws-sdk-secretsmanager' 7 | gem 'ox' 8 | gem 'pry' -------------------------------------------------------------------------------- /secrets-manager/basic/Readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/secrets-manager/basic/Readme.md -------------------------------------------------------------------------------- /secrets-manager/basic/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy secrets manager stuff" 4 | 5 | STACK_NAME="aws-sm-basic" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --region ca-central-1 \ 13 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /secrets-manager/db/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy secrets manager db" 4 | 5 | STACK_NAME="aws-sm-db" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --no-execute-changeset \ 12 | --parameter-overrides VpcId="vpc-08f0ec02f7471b018" Subnets="subnet-0e0fd31733061237d,subnet-0377c6b172e2951d4,subnet-0d8058cb02f147a86" \ 13 | --region ca-central-1 \ 14 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /secrets-manager/mask/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy secrets manager mask" 4 | 5 | STACK_NAME="aws-sm-mask" 6 | 7 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 8 | aws cloudformation deploy \ 9 | --template-file template.yaml \ 10 | --capabilities CAPABILITY_NAMED_IAM \ 11 | --parameter-overrides MyPassword="!654321gnitesT" \ 12 | --no-execute-changeset \ 13 | --region ca-central-1 \ 14 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /secrets-manager/mask/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: "2010-09-09" 2 | Parameters: 3 | MyPassword: 4 | Type: String 5 | NoEcho: true 6 | Resources: 7 | MySecretPassed: 8 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-secretsmanager-secret.html 9 | Type: 'AWS::SecretsManager::Secret' 10 | Properties: 11 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-secretsmanager-secret-generatesecretstring.html 12 | SecretString: !Ref MyPassword -------------------------------------------------------------------------------- /sns/basic/.aws-sam/build.toml: -------------------------------------------------------------------------------- 1 | # This file is auto generated by SAM CLI build command 2 | 3 | [function_build_definitions] 4 | 5 | [layer_build_definitions] 6 | -------------------------------------------------------------------------------- /sns/basic/bin/publish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | TOPIC_ARN="arn:aws:sns:ca-central-1:982383527471:sns-basisc-lambda-SNSTopic-PX5aIoGcnICj" 6 | 7 | aws sns publish \ 8 | --topic-arn $TOPIC_ARN \ 9 | --message '{ "first_name": "Andrew", "last_name": "Brown" }' -------------------------------------------------------------------------------- /sqs/fifo/bin/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy SQS Standard" 4 | 5 | STACK_NAME="sqs-fifo" 6 | 7 | root_path=$(realpath .) 8 | template_path="${root_path}/template.yaml" 9 | 10 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 11 | aws cloudformation deploy \ 12 | --template-file $template_path \ 13 | --capabilities CAPABILITY_NAMED_IAM \ 14 | --no-execute-changeset \ 15 | --region ca-central-1 \ 16 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /sqs/fifo/bin/recieve: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== receieve" 3 | 4 | root_path=$(realpath .) 5 | 6 | QUEUE_URL=https://sqs.ca-central-1.amazonaws.com/982383527471/sqs-fifo-MyQueue-TFdtzZeh3R0e.fifo 7 | 8 | aws sqs receive-message \ 9 | --queue-url $QUEUE_URL \ 10 | --attribute-names All \ 11 | --message-attribute-names All \ 12 | --max-number-of-messages 10 -------------------------------------------------------------------------------- /sqs/fifo/send-message.json: -------------------------------------------------------------------------------- 1 | { 2 | "Fruit": { 3 | "DataType": "String", 4 | "StringValue": "Apple" 5 | } 6 | } -------------------------------------------------------------------------------- /sqs/fifo/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: "2010-09-09" 2 | Description: A Simple SQS queue 3 | Resources: 4 | MyQueue: 5 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sqs-queue.html 6 | Type: AWS::SQS::Queue 7 | Properties: 8 | FifoQueue: true 9 | # QueueName: "StandardQueue" -------------------------------------------------------------------------------- /sqs/standard/bin/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "== deploy SQS Standard" 4 | 5 | STACK_NAME="sqs-standard" 6 | 7 | root_path=$(realpath .) 8 | template_path="${root_path}/template.yaml" 9 | 10 | # https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html 11 | aws cloudformation deploy \ 12 | --template-file $template_path \ 13 | --capabilities CAPABILITY_NAMED_IAM \ 14 | --no-execute-changeset \ 15 | --region ca-central-1 \ 16 | --stack-name $STACK_NAME -------------------------------------------------------------------------------- /sqs/standard/bin/recieve: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "== receieve" 3 | 4 | root_path=$(realpath .) 5 | 6 | QUEUE_URL=https://sqs.ca-central-1.amazonaws.com/982383527471/sqs-standard-MyQueue-ONKfvvgwWJo2 7 | 8 | aws sqs receive-message \ 9 | --queue-url $QUEUE_URL \ 10 | --attribute-names All \ 11 | --message-attribute-names All \ 12 | --max-number-of-messages 10 -------------------------------------------------------------------------------- /sqs/standard/ruby/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem "ox" 7 | gem "aws-sdk-sqs" 8 | gem 'pry' -------------------------------------------------------------------------------- /sqs/standard/ruby/recieve.rb: -------------------------------------------------------------------------------- 1 | require 'aws-sdk-sqs' 2 | require 'pry' 3 | 4 | client = Aws::SQS::Client.new 5 | 6 | queue_url = "https://sqs.ca-central-1.amazonaws.com/982383527471/sqs-standard-MyQueue-ONKfvvgwWJo2" 7 | 8 | resp = client.receive_message({ 9 | queue_url: queue_url, 10 | attribute_names: ["All"], 11 | max_number_of_messages: 1, 12 | visibility_timeout: 1, 13 | wait_time_seconds: 1 14 | }) 15 | 16 | resp.messages.each do |message| 17 | puts message.receipt_handle 18 | puts message.body 19 | puts message.attributes.inspect 20 | handle = message.receipt_handle 21 | resp = client.delete_message({ 22 | queue_url: queue_url, 23 | receipt_handle: handle 24 | }) 25 | end -------------------------------------------------------------------------------- /sqs/standard/ruby/send.rb: -------------------------------------------------------------------------------- 1 | require 'aws-sdk-sqs' 2 | 3 | client = Aws::SQS::Client.new 4 | 5 | queue_url = "https://sqs.ca-central-1.amazonaws.com/982383527471/sqs-standard-MyQueue-ONKfvvgwWJo2" 6 | 7 | resp = client.send_message({ 8 | queue_url: queue_url, 9 | message_body: "Hello Ruby!", 10 | delay_seconds: 1, 11 | message_attributes: { 12 | "Fruit" => { 13 | string_value: "Apple", 14 | data_type: "String" 15 | } 16 | } 17 | }) -------------------------------------------------------------------------------- /sqs/standard/send-message.json: -------------------------------------------------------------------------------- 1 | { 2 | "Fruit": { 3 | "DataType": "String", 4 | "StringValue": "Apple" 5 | } 6 | } -------------------------------------------------------------------------------- /sqs/standard/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: "2010-09-09" 2 | Description: A Simple SQS queue 3 | Resources: 4 | MyQueue: 5 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sqs-queue.html 6 | Type: AWS::SQS::Queue 7 | #Properties: 8 | # QueueName: "StandardQueue" -------------------------------------------------------------------------------- /step-functions/star-trek/Readme.md: -------------------------------------------------------------------------------- 1 | ## Create Bucket 2 | 3 | aws s3 mb s3://sf-star-trek-131241 --region us-east-1 -------------------------------------------------------------------------------- /step-functions/star-trek/dukat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/step-functions/star-trek/dukat.jpg -------------------------------------------------------------------------------- /step-functions/star-trek/event-pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "source": [ 3 | "aws.s3" 4 | ], 5 | "detail-type": [ 6 | "Object Created" 7 | ], 8 | "detail": { 9 | "bucket": { 10 | "name": ["sf-star-trek-131241"] 11 | }, 12 | "object": { 13 | "key": [{"prefix": "inputs/"}] 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /step-functions/star-trek/flow.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/step-functions/star-trek/flow.yml -------------------------------------------------------------------------------- /step-functions/star-trek/picard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/step-functions/star-trek/picard.jpg -------------------------------------------------------------------------------- /textract/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem 'aws-sdk-textract' 7 | gem 'ox' 8 | gem 'pry' -------------------------------------------------------------------------------- /textract/Readme.md: -------------------------------------------------------------------------------- 1 | aws s3 mb s3://textract-exp-41241 --region ca-central-1 2 | aws s3 cp tax-doc.png s3://textract-exp-41241 -------------------------------------------------------------------------------- /textract/main.rb: -------------------------------------------------------------------------------- 1 | require 'aws-sdk-textract' 2 | require 'pry' 3 | 4 | client = Aws::Textract::Client.new region: 'ca-central-1' 5 | bucket = 'textract-exp-41241' 6 | name = 'tax-doc.png' 7 | resp = client.analyze_document({ 8 | document: { # required 9 | s3_object: { 10 | bucket: bucket, 11 | name: name#, 12 | #version: "S3ObjectVersion", 13 | }, 14 | }, 15 | # required, accepts TABLES, FORMS, QUERIES, SIGNATURES, LAYOUT 16 | feature_types: ["TABLES"] 17 | }) 18 | #binding.pry -------------------------------------------------------------------------------- /textract/tax-doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/textract/tax-doc.png -------------------------------------------------------------------------------- /translate/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # gem "rails" 6 | gem "aws-sdk-translate" 7 | gem 'pry' 8 | gem 'nokogiri' -------------------------------------------------------------------------------- /translate/main.rb: -------------------------------------------------------------------------------- 1 | require 'aws-sdk-translate' 2 | require 'pry' 3 | 4 | client = Aws::Translate::Client.new 5 | 6 | text = "Hello, This is Andrew Brown, Utilizing Amazon Translate." 7 | resp = client.translate_text({ 8 | text: text, 9 | source_language_code: "en", # required 10 | target_language_code: "es" # required 11 | }) 12 | puts resp.translated_text -------------------------------------------------------------------------------- /vpc/sg/Readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExamProCo/AWS-Examples/9af77978560412a6457612675f4e17d520fa7ffc/vpc/sg/Readme.md --------------------------------------------------------------------------------