- Notifications
You must be signed in to change notification settings - Fork 5.8k
Update Ruby Readmes for SoS #2225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits Select commit Hold shift + click to select a range
ed11f19 update READMEs
brmur c900e5c update READMEs
brmur 3b96a3a update READMEs
brmur d4556b5 Merge branch 'main' into update_READMEs
brmur 2c9af14 update READMEs
brmur bda43ce Merge remote-tracking branch 'origin/update_READMEs' into update_READMEs
brmur 341ab1b update READMEs
brmur 075ac3c update READMEs
brmur 2784503 update READMEs
brmur 9139fa2 update READMEs
brmur f6021ad update READMEs
brmur 2d0dc18 update READMEs
brmur dc9938a update READMEs
brmur 6c771a4 update READMEs
brmur 718ed5b update READMEs
brmur 869850b implementing edits
brmur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Amazon Cloudwatch JavaScript SDK v2 code examples | ||
| Amazon Cloudwatch enables you to collect, access, and correlate data on a single platform from across all your AWS resources, applications, and services. | ||
| | ||
| ## Code examples | ||
| This is a workspace where you can find the following AWS SDK for JavaScript version 2 (v2) Amazon Cloudwatch examples: | ||
| | ||
| - [Delete CloudWatch alarms](./cw_deletealarms.js) | ||
| - [Describe CloudWatch alarms](./cw_describealarms.js) | ||
| - [Disable CloudWatch alarm actions](./cw_disablealarmactions.js) | ||
| - [Enable CloudWatch alarm actions](./cw_enablealarmactions.js) | ||
| - [List CloudWatch metrics](./cw_listmetrics.js) | ||
| - [Put CloudWatch metric alarms](./cw_putmetricalarm.js) | ||
| - [Put CloudWatch metric data](./cw_putmetricdata.js) | ||
| - [Put CloudWatch events](./cwe_putevents.js) | ||
| - [Put CloudWatch event rule](./cwe_putRule.js) | ||
| - [Put CloudWatch event targets](./cwe_putTargets.js) | ||
| - [Delete a CloudWatch log subscription filters](./cwe_deletesubscriptionfilter.js) | ||
| - [Describe CloudWatch log subscription filters](./cwe_describesubscriptionfilters.js) | ||
| - [Put CloudWatch log subscription filter](./cwe_putsubscriptionfilter.js) | ||
| | ||
| ## Resources | ||
| | ||
| - [AWS SDK for JavaScript v2 Developer Guide](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/cloudwatch-examples.html) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # AWS SDK for Ruby code examples for AWS CloudTrail | ||
| | ||
| ## Purpose | ||
| | ||
| This folder contains code examples that demonstrate how to use the AWS SDK for Ruby to automate AWS CloudTrail. | ||
| | ||
| ## Code examples | ||
| This is a workspace where you can find the following AWS SDK for Ruby version 3 (v3) AWS CloudTrail examples: | ||
| | ||
| ### API examples | ||
| - [Create a trail](./aws-ruby-sdk-cloudtrail-example-create-trail.rb) | ||
| - [Delete a trail](./aws-ruby-sdk-cloudtrail-example-delete-trail.rb) | ||
| - [Describe trails](./aws-ruby-sdk-cloudtrail-example-describe-trails.rb) | ||
| - [Lookup events](./aws-ruby-sdk-cloudtrail-example-lookup-events.rb) | ||
| | ||
| ## Important | ||
| | ||
| - As an AWS best practice, grant this code least privilege, or only the | ||
| permissions required to perform a task. For more information, see | ||
| [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege) | ||
| in the *AWS Identity and Access Management User Guide*. | ||
| - This code has not been tested in all AWS Regions. Some AWS services are | ||
| available only in specific AWS Regions. For more information, see the | ||
| [AWS Regional Services List](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/) | ||
| on the AWS website. | ||
| - Running this code might result in charges to your AWS account. | ||
| | ||
| ## Running the code | ||
| | ||
| Most of these code example files can be run with very little to no modification. For example, to use Ruby to run the `cw-ruby-example-create-alarm.rb` file, replace the hard-coded values in the file with your own values, save the file, and then run the file. For example: | ||
| | ||
| ``` | ||
| ruby cw-ruby-example-create-alarm.rb | ||
| ``` | ||
| | ||
| Most of these files have been refactored into reusable functions that can be copied into your own code. You can then call those functions directly from your own code without modifying the copied function code itself. For example, you could copy the `alarm_created_or_updated?` function code from the `cw-ruby-example-create-alarm.rb` file into your own code. You could then adapt the code in the `run_me` function in that same file as a basis to write your own code to call the copied `alarm_created_or_updated?` function. | ||
brmur marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| | ||
| ## Running the tests | ||
| | ||
| ### Prerequisites | ||
brmur marked this conversation as resolved. Show resolved Hide resolved | ||
| | ||
| - An AWS account. To create an account, see [How do I create and activate a new AWS account](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/) on the AWS Premium Support website. | ||
| - AWS credentials or an AWS Security Token Service (AWS STS) access token. For details, see | ||
| [Configuring the AWS SDK for Ruby](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html) in the | ||
| *AWS SDK for Ruby Developer Guide*. | ||
| - To run the code examples, Ruby version 1.9 or later. For Ruby download and installation instructions, see | ||
| [Download Ruby](https://www.ruby-lang.org/en/downloads/) on the Ruby Progamming Language website. | ||
| - To test the code examples, RSpec 3.9 or later. For RSpec download and installation instructions, see the [rspec/rspec](https://github.com/rspec/rspec) repository in GitHub. | ||
| - The AWS SDK for Ruby. For AWS SDK for Ruby download and installation instructions, see | ||
| [Install the AWS SDK for Ruby](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-install.html) in the | ||
| *AWS SDK for Ruby Developer Guide*. | ||
| | ||
| | ||
| Most of these code example files have accompanying tests that are written to work with RSpec. These tests are in the `tests` folder and contain the same file name as the corresponding code example file, for example `tests/test_cw-ruby-example-create-alarm.rb` contains tests for `cw-ruby-example-create-alarm.rb`. | ||
| | ||
| To use RSpec to run all tests within a file, specify the path to that file, for example: | ||
| | ||
| ``` | ||
| rspec tests/test_cw-ruby-example-create-alarm.rb | ||
| ``` | ||
| | ||
| To explore additional options for using RSpec to run tests, run the `rspec --help` command. | ||
| | ||
| Most of these tests are designed to use stubs, to avoid generating unnecessary costs in an AWS account. For more information, see [Stubbing Client Responses and Errors](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/stubbing.html) in the *AWS SDK for Ruby Developer Guide*. | ||
| | ||
| | ||
| ## Additional information | ||
| - [AWS CloudTrail Documentation](https://docs.aws.amazon.com/cloudtrail/) | ||
| - [AWS SDK for Ruby Documentation](https://docs.aws.amazon.com/sdk-for-ruby) | ||
| - [AWS Tools and SDKs Shared Configuration and Credentials Reference Guide](https://docs.aws.amazon.com/credref/latest/refdocs) | ||
| - [RSpec Documentation](https://rspec.info/documentation) | ||
| | ||
| --- | ||
| Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| | ||
| SPDX-License-Identifier: Apache-2.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
39 changes: 14 additions & 25 deletions 39 ruby/example_code/cloudtrail/aws-ruby-sdk-cloudtrail-example-describe-trails.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,28 @@ | ||
| # snippet-comment:[These are tags for the AWS doc team's sample catalog. Do not remove.] | ||
| # snippet-sourceauthor:[Doug-AWS] | ||
| # snippet-sourcedescription:[Lists your CloudTrail trails.] | ||
| # snippet-keyword:[AWS CloudTrail] | ||
| # snippet-keyword:[describe_trails method] | ||
| # snippet-keyword:[Ruby] | ||
| # snippet-sourcesyntax:[ruby] | ||
| # snippet-service:[cloudtrail] | ||
| # snippet-keyword:[Code Sample] | ||
| # snippet-sourcetype:[full-example] | ||
| # snippet-sourcedate:[2018-03-16] | ||
| # Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # | ||
| # This file is licensed under the Apache License, Version 2.0 (the "License"). | ||
| # You may not use this file except in compliance with the License. A copy of the | ||
| # License is located at | ||
| # | ||
| # http://aws.amazon.com/apache2.0/ | ||
| # | ||
| # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
| # OF ANY KIND, either express or implied. See the License for the specific | ||
| # language governing permissions and limitations under the License. | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| | ||
| # Purpose: | ||
| # aws-ruby-sdk-cloudtrail-example-describe-trails.rb demonstrates how to | ||
| # retrieve details about your an Amazon CloudTrail trails using the AWS SDK for Ruby. | ||
brmur marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| | ||
| | ||
| # snippet-start:[cloudtrail.Ruby.describeTrails] | ||
| require 'aws-sdk-cloudtrail' # v2: require 'aws-sdk' | ||
| | ||
| # Create client in us-west-2 | ||
| client = Aws::CloudTrail::Client.new(region: 'us-west-2') | ||
| # Create client in us-west-2. | ||
| # Replace us-west-2 with the AWS Region you're using for AWS CloudTrail. | ||
| | ||
| client = Aws::CloudTrail::Client.new(region: 'REGION') | ||
| | ||
| resp = client.describe_trails({}) | ||
| | ||
| puts | ||
| puts "Found #{resp.trail_list.count} trail(s) in us-west-2:" | ||
| puts "Found #{resp.trail_list.count} trail(s) in REGION:" | ||
| puts | ||
| | ||
| resp.trail_list.each do |trail| | ||
| puts 'Name: ' + trail.name | ||
| puts 'S3 bucket name: ' + trail.s3_bucket_name | ||
| puts | ||
| end | ||
| # snippet-end:[cloudtrail.Ruby.describeTrails] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.