Skip to content

Commit b7dd9d7

Browse files
authored
Merge branch 'main' into main
2 parents e8a4cd3 + 387d729 commit b7dd9d7

File tree

28 files changed

+1233
-510
lines changed

28 files changed

+1233
-510
lines changed

.doc_gen/metadata/cloudwatch-logs_metadata.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,13 @@ cloudwatch-logs_DescribeLogStreams:
116116
Java:
117117
versions:
118118
- sdk_version: 2
119-
github: javav2/example_code/cloudwatch
119+
github: javav2/example_code/cloudwatch-logs
120120
sdkguide:
121121
excerpts:
122-
- description:
122+
- description: Searches for log streams within a specified log group that match a given prefix.
123+
snippet_tags:
124+
- cloudwatch.javav2.read.log.streams.main
125+
- description: Prints metadata about the most recent log stream in a specified log group.
123126
snippet_tags:
124127
- cloudwatch.javav2.describe.log.streams.main
125128
services:
@@ -158,7 +161,7 @@ cloudwatch-logs_DescribeSubscriptionFilters:
158161
Java:
159162
versions:
160163
- sdk_version: 2
161-
github: javav2/example_code/cloudwatch
164+
github: javav2/example_code/cloudwatch-logs
162165
sdkguide:
163166
excerpts:
164167
- description:
@@ -208,7 +211,7 @@ cloudwatch-logs_DeleteSubscriptionFilter:
208211
Java:
209212
versions:
210213
- sdk_version: 2
211-
github: javav2/example_code/cloudwatch
214+
github: javav2/example_code/cloudwatch-logs
212215
sdkguide:
213216
excerpts:
214217
- description:
@@ -248,7 +251,7 @@ cloudwatch-logs_PutSubscriptionFilter:
248251
Java:
249252
versions:
250253
- sdk_version: 2
251-
github: javav2/example_code/cloudwatch
254+
github: javav2/example_code/cloudwatch-logs
252255
sdkguide:
253256
excerpts:
254257
- description:

.github/workflows/sync-S3-KB.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: syncS3andKB
2+
on:
3+
push:
4+
branches: ["main"]
5+
workflow_dispatch:
6+
inputs:
7+
sdk_name:
8+
description: 'SDK Name'
9+
required: true
10+
default: 'python'
11+
type: choice
12+
options:
13+
- javascriptv3
14+
- dotnetv4
15+
- javav2
16+
- rustv1
17+
- gov2
18+
- swift
19+
- python
20+
- ruby
21+
- php
22+
- cpp
23+
- kotlin
24+
25+
permissions:
26+
id-token: write
27+
28+
jobs:
29+
run_job_with_aws:
30+
runs-on: ubuntu-latest
31+
env:
32+
sdk_name: ${{ github.event.inputs.sdk_name || 'python' }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Configure AWS Credentials
39+
uses: aws-actions/configure-aws-credentials@v5
40+
with:
41+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} # once merged, update trust policy of the role to point to main branch
42+
aws-region: us-west-2
43+
44+
- name: Set SDK and language mapping for S3
45+
run: |
46+
if [ "$sdk_name" == "javascriptv3" ]; then
47+
echo "S3_LANGUAGE=javascript" >> $GITHUB_ENV
48+
elif [ "$sdk_name" == "dotnetv4" ]; then
49+
echo "S3_LANGUAGE=dotnet" >> $GITHUB_ENV
50+
elif [ "$sdk_name" == "javav2" ]; then
51+
echo "S3_LANGUAGE=java" >> $GITHUB_ENV
52+
elif [ "$sdk_name" == "rustv1" ]; then
53+
echo "S3_LANGUAGE=rust" >> $GITHUB_ENV
54+
elif [ "$sdk_name" == "gov2" ]; then
55+
echo "S3_LANGUAGE=go" >> $GITHUB_ENV
56+
else
57+
echo "S3_LANGUAGE=$sdk_name" >> $GITHUB_ENV
58+
fi
59+
60+
- name: Extract and copy premium examples in temp. dir.
61+
run: |
62+
MARKDOWN_FILE="./$sdk_name/premium-ex.md"
63+
64+
if [ ! -f "$MARKDOWN_FILE" ]; then
65+
echo "Premium examples file not found: $MARKDOWN_FILE"
66+
exit 1
67+
fi
68+
69+
extract_paths() {
70+
local level="$1"
71+
local section_found=false
72+
73+
while IFS= read -r line; do
74+
if [[ "$line" =~ ^##[[:space:]]*${level}:[[:space:]]*$ ]]; then
75+
section_found=true
76+
continue
77+
elif [[ "$line" =~ ^##[[:space:]] ]] && [ "$section_found" = true ]; then
78+
break
79+
elif [ "$section_found" = true ] && [[ "$line" =~ ^/ ]]; then
80+
echo "$line"
81+
fi
82+
done < "$MARKDOWN_FILE"
83+
}
84+
85+
for level in "basics" "feature-scenario" "complex-feature-scenario"; do
86+
paths=$(extract_paths "$level")
87+
88+
if [ -n "$paths" ]; then
89+
mkdir -p "./extracted_snippets/$level"
90+
91+
while IFS= read -r path; do
92+
if [ -n "$path" ]; then
93+
source_path="./$sdk_name$path"
94+
if [ -e "$source_path" ]; then
95+
cp -r "$source_path" "./extracted_snippets/$level/"
96+
fi
97+
fi
98+
done <<< "$paths"
99+
fi
100+
done
101+
102+
- name: Upload/Sync to S3
103+
run: |
104+
for level in "basics" "feature-scenario" "complex-feature-scenario"; do
105+
if [ -d "./extracted_snippets/$level" ]; then
106+
aws s3 sync "./extracted_snippets/$level/" "s3://$S3_LANGUAGE-premium-bucket/$level/" --delete
107+
echo "Uploaded $level examples to S3"
108+
fi
109+
done
110+
111+
- name: Sync Knowledge Base Data Source
112+
run: |
113+
aws lambda invoke \
114+
--function-name KB_Updater \
115+
--payload "{\"language\":\"$S3_LANGUAGE\",\"region\":\"us-west-2\"}" \
116+
--cli-binary-format raw-in-base64-out \
117+
response.json
118+
119+
echo "Knowledge Base sync initiated"
120+
cat response.json

cpp/premium-ex.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//Add paths for premium examples here which will be consumed by workflow to update KB with quality code
2+
3+
## basics:
4+
/example_code/s3/s3_getting_started_scenario.cpp
5+
6+
## feature-scenario:
7+
/example_code/medical-imaging/imaging_set_and_frames_workflow
8+
9+
## complex-feature-scenario:
10+
/example_code/s3/s3_object_integrity_workflow

dotnetv4/premium-ex.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//Add paths for premium examples here which will be consumed by workflow to update KB with quality code
2+
//Don't forget to add new line at the end of this file
3+
4+
## basics:
5+
/ControlTower
6+
7+
## feature-scenario:
8+
/CloudWatch/Scenarios
9+
10+
## complex-feature-scenario:
11+
/S3/Scenarios/S3_CreatePresignedPost

gov2/premium-ex.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//Add paths for premium examples here which will be consumed by workflow to update KB with quality code
2+
//Don't forget to add new line at the end of this file
3+
4+
## basics:
5+
/s3/actions/bucket_basics.go
6+
7+
## feature-scenario:
8+
/s3/actions/bucket_basics.go
9+
10+
## complex-feature-scenario:
11+
/dynamodb/scenarios/scenario_movie_table.go

javascriptv3/premium-ex.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//Add paths for premium examples here which will be consumed by workflow to update KB with quality code
2+
//Don't forget to add new line at the end of this file
3+
4+
## basics:
5+
/example_code/s3/scenarios/basic.js
6+
7+
## feature-scenario:
8+
/example_code/s3/scenarios/object-locking
9+
10+
## complex-feature-scenario:
11+
/example_code/bedrock-runtime/scenarios/converse_tool_scenario/converse-tool-scenario.js
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# CloudWatch Logs code examples for the SDK for Java 2.x
2+
3+
## Overview
4+
5+
Shows how to use the AWS SDK for Java 2.x to work with Amazon CloudWatch Logs.
6+
7+
<!--custom.overview.start-->
8+
<!--custom.overview.end-->
9+
10+
_CloudWatch Logs monitor, store, and access your log files from Amazon Elastic Compute Cloud instances, AWS CloudTrail, or other sources._
11+
12+
## ⚠ Important
13+
14+
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
15+
* Running the tests might result in charges to your AWS account.
16+
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
17+
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
18+
19+
<!--custom.important.start-->
20+
<!--custom.important.end-->
21+
22+
## Code examples
23+
24+
### Prerequisites
25+
26+
For prerequisites, see the [README](../../README.md#Prerequisites) in the `javav2` folder.
27+
28+
29+
<!--custom.prerequisites.start-->
30+
<!--custom.prerequisites.end-->
31+
32+
### Single actions
33+
34+
Code excerpts that show you how to call individual service functions.
35+
36+
- [DeleteSubscriptionFilter](src/main/java/com/example/logs/DeleteSubscriptionFilter.java#L6)
37+
- [DescribeLogStreams](src/main/java/com/example/logs/CloudWatchLogsSearch.java#L18)
38+
- [DescribeSubscriptionFilters](src/main/java/com/example/logs/DescribeSubscriptionFilters.java#L6)
39+
- [GetLogEvents](src/main/java/com/example/logs/GetLogEvents.java#L6)
40+
- [PutSubscriptionFilter](src/main/java/com/example/logs/PutSubscriptionFilter.java#L6)
41+
42+
43+
<!--custom.examples.start-->
44+
<!--custom.examples.end-->
45+
46+
## Run the examples
47+
48+
### Instructions
49+
50+
51+
<!--custom.instructions.start-->
52+
<!--custom.instructions.end-->
53+
54+
55+
56+
### Tests
57+
58+
⚠ Running tests might result in charges to your AWS account.
59+
60+
61+
To find instructions for running these tests, see the [README](../../README.md#Tests)
62+
in the `javav2` folder.
63+
64+
65+
66+
<!--custom.tests.start-->
67+
<!--custom.tests.end-->
68+
69+
## Additional resources
70+
71+
- [CloudWatch Logs User Guide](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)
72+
- [CloudWatch Logs API Reference](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/Welcome.html)
73+
- [SDK for Java 2.x CloudWatch Logs reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/cloudwatch-logs/package-summary.html)
74+
75+
<!--custom.resources.start-->
76+
<!--custom.resources.end-->
77+
78+
---
79+
80+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
81+
82+
SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)