Skip to content

Commit 876fdb3

Browse files
tejasgn1Tejas Ganesh Naikrlhagermbeqqrry-aws
authored
CodeLoom-4-Bedrock (#7622)
* codeloom for bedrock changes * updated steering files and created lang. specific tech files * updated steering docs to implement stricter guardrails and added README * adding more guardrails * Updates for .NET steering. * Made steering doc changes; added separate python directory * kiro directory cleanup and readding dotnet tech doc changes * put back common python-tech.md * Add separate dotnet tech docs. * adding java and kotlin steering directories * Update .NET steering. * Update metadata.md * Update metadata.md --------- All the steering doc addition look good. Co-authored-by: Tejas Ganesh Naik <“tejasgn@amazon.com”> Co-authored-by: Rachel Hagerman <110480692+rlhagerm@users.noreply.github.com> Co-authored-by: Jason Q <81179619+beqqrry-aws@users.noreply.github.com>
1 parent 641a6ed commit 876fdb3

36 files changed

+9832
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Amazon GuardDuty Specification
2+
3+
This document contains a draft proposal for a Code Example for *Amazon GuardDuty Basics Scenario*, generated by the Code Examples SpecGen AI tool. The specifications describe a potential code example scenario based on research, usage data, service information, and AI-assistance. The following should be reviewed for accuracy and correctness before proceeding on to a final specification.
4+
5+
### Relevant documentation
6+
7+
* [Getting started with GuardDuty](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_settingup.html)
8+
* [What is Amazon GuardDuty?](https://docs.aws.amazon.com/guardduty/latest/ug/what-is-guardduty.html)
9+
* [Amazon GuardDuty API Reference](https://docs.aws.amazon.com/guardduty/latest/APIReference/Welcome.html)
10+
* [GuardDuty Pricing](https://aws.amazon.com/guardduty/pricing/)
11+
12+
### API Actions Used
13+
14+
* [CreateDetector](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_CreateDetector.html)
15+
* [GetDetector](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_GetDetector.html)
16+
* [ListDetectors](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html)
17+
* [CreateSampleFindings](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_CreateSampleFindings.html)
18+
* [ListFindings](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListFindings.html)
19+
* [GetFindings](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_GetFindings.html)
20+
* [DeleteDetector](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_DeleteDetector.html)
21+
22+
## Proposed example structure
23+
24+
The details below describe how this example would run for the customer. It includes a Hello service example (included for all services), and the scenario details. The scenario code would also be presented as Action snippets, with a code snippet for each SDK action.
25+
26+
### Hello
27+
28+
The Hello example is a separate runnable example. - Set up the GuardDuty service client - Check if GuardDuty is available in the current region - List any existing detectors
29+
30+
## Scenario
31+
32+
#### Setup
33+
34+
* Create a GuardDuty detector to enable threat detection
35+
* Verify the detector is successfully created and active
36+
* Display detector configuration and status
37+
38+
#### Sample Findings Generation
39+
40+
* Generate sample findings to demonstrate GuardDuty capabilities
41+
* List the generated sample findings
42+
* Display finding details including severity and type
43+
44+
#### Findings Management
45+
46+
* Retrieve detailed information about specific findings
47+
* Filter findings by severity level
48+
* Display finding metadata and threat information
49+
50+
#### Cleanup
51+
52+
* Archive or acknowledge sample findings
53+
* Optionally disable the detector (with user confirmation)
54+
* Clean up resources created during the example
55+
56+
## Errors
57+
58+
SDK Code examples include basic exception handling for each action used. The table below describes an appropriate exception which will be handled in the code for each service action.
59+
60+
|Action |Error |Handling |
61+
|--- |--- |--- |
62+
|`CreateDetector` |BadRequestException |Validate input parameters and notify user of invalid configuration. |
63+
|`CreateDetector` |InternalServerErrorException |Retry operation with exponential backoff. |
64+
|`GetDetector` |BadRequestException |Validate detector ID format and existence. |
65+
|`GetDetector` |InternalServerErrorException |Retry operation and handle service unavailability. |
66+
|`ListDetectors` |BadRequestException |Validate pagination parameters and retry. |
67+
|`ListDetectors` |InternalServerErrorException |Handle service errors gracefully. |
68+
|`CreateSampleFindings` |BadRequestException |Validate detector ID and finding types. |
69+
|`CreateSampleFindings` |InternalServerErrorException |Retry sample finding generation. |
70+
|`ListFindings` |BadRequestException |Validate finding criteria and pagination. |
71+
|`GetFindings` |BadRequestException |Validate finding IDs format. |
72+
|`DeleteDetector` |BadRequestException |Confirm detector exists before deletion. |
73+
|`DeleteDetector` |InternalServerErrorException |Handle deletion failures gracefully. |
74+
75+
## Metadata
76+
77+
|action / scenario |metadata file |metadata key |
78+
|--- |--- |--- |
79+
|`CreateDetector` |guardduty_metadata.yaml |guardduty_CreateDetector |
80+
|`GetDetector` |guardduty_metadata.yaml |guardduty_GetDetector |
81+
|`ListDetectors` |guardduty_metadata.yaml |guardduty_ListDetectors |
82+
|`CreateSampleFindings` |guardduty_metadata.yaml |guardduty_CreateSampleFindings |
83+
|`ListFindings` |guardduty_metadata.yaml |guardduty_ListFindings |
84+
|`GetFindings` |guardduty_metadata.yaml |guardduty_GetFindings |
85+
|`DeleteDetector` |guardduty_metadata.yaml |guardduty_DeleteDetector |
86+
|`Amazon GuardDuty Basics Scenario` |guardduty_metadata.yaml |guardduty_Scenario |
87+
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Amazon Inspector Specification
2+
3+
This document contains a draft proposal for an *Amazon Inspector Basics Scenario*, generated by the Code Examples SpecGen AI tool. The specifications describe a potential code example scenario based on research, usage data, service information, and AI-assistance. The following should be reviewed for accuracy and correctness before proceeding on to a final specification.
4+
5+
### Relevant documentation
6+
7+
* [Getting started with Amazon Inspector](https://docs.aws.amazon.com/inspector/latest/user/getting_started.html)
8+
* [What is Amazon Inspector?](https://docs.aws.amazon.com/inspector/latest/user/what-is-inspector.html)
9+
* [Amazon Inspector API Reference](https://docs.aws.amazon.com/inspector/v2/APIReference/Welcome.html)
10+
* [Amazon Inspector Pricing](https://aws.amazon.com/inspector/pricing/)
11+
12+
### API Actions Used
13+
14+
* [Enable](https://docs.aws.amazon.com/inspector/v2/APIReference/API_Enable.html)
15+
* [BatchGetAccountStatus](https://docs.aws.amazon.com/inspector/v2/APIReference/API_BatchGetAccountStatus.html)
16+
* [ListFindings](https://docs.aws.amazon.com/inspector/v2/APIReference/API_ListFindings.html)
17+
* [BatchGetFindingDetails](https://docs.aws.amazon.com/inspector/v2/APIReference/API_BatchGetFindingDetails.html)
18+
* [ListCoverage](https://docs.aws.amazon.com/inspector/v2/APIReference/API_ListCoverage.html)
19+
* [Disable](https://docs.aws.amazon.com/inspector/v2/APIReference/API_Disable.html)
20+
21+
## Proposed example structure
22+
23+
The output below demonstrates how this example would run for the customer. It includes a Hello service example (included for all services), and the scenario description. The scenario code would also be presented as Action snippets, with a code snippet for each SDK action.
24+
25+
### Hello
26+
27+
The Hello example is a separate runnable example. - Set up the Inspector service client - Check the current account status for Inspector - Display available scan types and regions
28+
29+
## Scenario
30+
31+
#### Setup
32+
33+
* Enable Amazon Inspector for the account
34+
* Verify Inspector is successfully activated
35+
* Display account status and enabled scan types
36+
37+
#### Coverage Assessment
38+
39+
* List coverage statistics for EC2 instances, ECR repositories, and Lambda functions
40+
* Display resource coverage details
41+
* Show scanning status for different resource types
42+
43+
#### Findings Management
44+
45+
* List security findings across all resource types
46+
* Filter findings by severity level (CRITICAL, HIGH, MEDIUM, LOW)
47+
* Retrieve detailed information for specific findings
48+
49+
#### Vulnerability Analysis
50+
51+
* Display vulnerability details including CVE information
52+
* Show affected resources and remediation guidance
53+
* Filter findings by resource type (EC2, ECR, Lambda)
54+
55+
#### Cleanup
56+
57+
* Optionally disable Inspector scanning (with user confirmation)
58+
* Display final account status
59+
60+
## Errors
61+
62+
SDK Code examples include basic exception handling for each action used. The table below describes an appropriate exception which will be handled in the code for each service action.
63+
64+
|Action |Error |Handling |
65+
|--- |--- |--- |
66+
|`Enable` |ValidationException |Validate resource types and account permissions. |
67+
|`Enable` |AccessDeniedException |Notify user of insufficient permissions and exit. |
68+
|`BatchGetAccountStatus` |ValidationException |Validate account IDs format. |
69+
|`BatchGetAccountStatus` |AccessDeniedException |Handle permission errors gracefully. |
70+
|`ListFindings` |ValidationException |Validate filter criteria and pagination parameters. |
71+
|`ListFindings` |InternalServerException |Retry operation with exponential backoff. |
72+
|`BatchGetFindingDetails` |ValidationException |Validate finding ARNs format. |
73+
|`BatchGetFindingDetails` |AccessDeniedException |Handle access denied for specific findings. |
74+
|`ListCoverage` |ValidationException |Validate filter and pagination parameters. |
75+
|`Disable` |ValidationException |Validate resource types for disabling. |
76+
|`Disable` |ConflictException |Handle cases where Inspector cannot be disabled. |
77+
78+
## Metadata
79+
80+
|action / scenario |metadata file |metadata key |
81+
|--- |--- |--- |
82+
|`Enable` |inspector_metadata.yaml |inspector_Enable |
83+
|`BatchGetAccountStatus` |inspector_metadata.yaml |inspector_BatchGetAccountStatus |
84+
|`ListFindings` |inspector_metadata.yaml |inspector_ListFindings |
85+
|`BatchGetFindingDetails` |inspector_metadata.yaml |inspector_BatchGetFindingDetails |
86+
|`ListCoverage` |inspector_metadata.yaml |inspector_ListCoverage |
87+
|`Disable` |inspector_metadata.yaml |inspector_Disable |
88+
|`Amazon Inspector Basics Scenario` |inspector_metadata.yaml |inspector_Scenario |
89+

steering_docs/dotnet-tech.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# .NET Technology Stack & Build System
2+
3+
## .NET 8+ Development Environment
4+
5+
### Build Tools & Dependencies
6+
- **Build System**: dotnet CLI
7+
- **Package Manager**: NuGet
8+
- **Testing Framework**: xUnit
9+
- **Code Formatting**: dotnet-format
10+
- **SDK Version**: AWS SDK for .NET v4
11+
- **.NET Version**: .NET 8+
12+
13+
### Common Build Commands
14+
15+
```bash
16+
# Build and Package
17+
dotnet build SOLUTION.sln # Build solution
18+
dotnet build PROJECT.csproj # Build specific project
19+
dotnet clean # Clean build artifacts
20+
21+
# Testing
22+
dotnet test # Run all tests
23+
dotnet test --filter Category=Integration # Run integration tests
24+
dotnet test --logger trx # Run tests with detailed output
25+
26+
# Execution
27+
dotnet run # Run project
28+
dotnet run --project PROJECT.csproj # Run specific project
29+
30+
# Code Quality
31+
dotnet format # Format code
32+
```
33+
34+
### .NET-Specific Pattern Requirements
35+
36+
#### File Naming Conventions
37+
- Use PascalCase for class names and file names
38+
- Service prefix pattern: `{Service}Actions.cs` (e.g., `S3Actions.cs`)
39+
- Hello scenarios: `Hello{Service}.cs` (e.g., `HelloS3.cs`)
40+
- Test files: `{Service}Tests.cs`
41+
42+
#### Hello Scenario Structure
43+
- **Class naming**: `Hello{Service}.cs` class with main method
44+
- **Method structure**: Static Main method as entry point
45+
- **Documentation**: Include XML documentation explaining the hello example purpose
46+
47+
#### Code Structure Standards
48+
- **Namespace naming**: Use reverse domain notation (e.g., `Amazon.DocSamples.S3`)
49+
- **Class structure**: One public class per file matching filename
50+
- **Method naming**: Use PascalCase for method names
51+
- **Properties**: Use PascalCase for property names
52+
- **Constants**: Use PascalCase for constants
53+
- **Async methods**: Suffix with `Async` (e.g., `ListBucketsAsync`)
54+
55+
#### Dependency Injection Patterns
56+
```csharp
57+
/// <summary>
58+
/// Main entry point for the AWS Control Tower basics scenario.
59+
/// </summary>
60+
/// <param name="args">Command line arguments.</param>
61+
public static async Task Main(string[] args)
62+
{
63+
using var host = Host.CreateDefaultBuilder(args)
64+
.ConfigureServices((_, services) =>
65+
services.AddAWSService<IAmazonControlTower>()
66+
.AddAWSService<IAmazonControlCatalog>()
67+
.AddAWSService<IAmazonOrganizations>()
68+
.AddAWSService<IAmazonSecurityTokenService>()
69+
.AddTransient<ControlTowerWrapper>()
70+
)
71+
.Build();
72+
73+
logger = LoggerFactory.Create(builder => { builder.AddConsole(); })
74+
.CreateLogger<ControlTowerBasics>();
75+
76+
wrapper = host.Services.GetRequiredService<ControlTowerWrapper>();
77+
orgClient = host.Services.GetRequiredService<IAmazonOrganizations>();
78+
stsClient = host.Services.GetRequiredService<IAmazonSecurityTokenService>();
79+
80+
await RunScenario();
81+
}
82+
```
83+
84+
#### Error Handling Patterns
85+
```csharp
86+
using Amazon.S3;
87+
using Amazon.S3.Model;
88+
using System;
89+
using System.Threading.Tasks;
90+
91+
public class ExampleClass
92+
{
93+
public async Task ExampleMethodAsync()
94+
{
95+
var s3Client = new AmazonS3Client();
96+
97+
try
98+
{
99+
var response = await s3Client.ListBucketsAsync();
100+
// Process response
101+
Console.WriteLine($"Found {response.Buckets.Count} buckets");
102+
}
103+
catch (AmazonS3Exception e)
104+
{
105+
// Handle S3-specific exceptions
106+
Console.WriteLine($"S3 Error: {e.Message}");
107+
Console.WriteLine($"Error Code: {e.ErrorCode}");
108+
throw;
109+
}
110+
catch (Exception e)
111+
{
112+
// Handle general exceptions
113+
Console.WriteLine($"Error: {e.Message}");
114+
throw;
115+
}
116+
finally
117+
{
118+
s3Client?.Dispose();
119+
}
120+
}
121+
}
122+
```
123+
124+
#### Testing Standards
125+
- **Test framework**: Use xUnit attributes (`[Fact]`, `[Theory]`)
126+
- **Integration tests**: Mark with `[Trait("Category", "Integration")]`
127+
- **Async testing**: Use `async Task` for async test methods
128+
- **Resource management**: Use `using` statements for AWS clients
129+
- **Test naming**: Use descriptive method names explaining test purpose
130+
131+
#### Project Structure
132+
```
133+
src/
134+
├── {Service}Examples/
135+
│ ├── Hello{Service}.cs
136+
│ ├── {Service}Actions.cs
137+
│ ├── {Service}Scenarios.cs
138+
│ └── {Service}Examples.csproj
139+
└── {Service}Examples.Tests/
140+
├── {Service}Tests.cs
141+
└── {Service}Examples.Tests.csproj
142+
```
143+
144+
#### Documentation Requirements
145+
- **XML documentation**: Use `///` for class and method documentation
146+
- **Parameter documentation**: Document all parameters with `<param>`
147+
- **Return documentation**: Document return values with `<returns>`
148+
- **Exception documentation**: Document exceptions with `<exception>`
149+
- **README sections**: Include dotnet setup and execution instructions
150+
151+
### AWS Credentials Handling
152+
153+
#### Critical Credential Testing Protocol
154+
- **CRITICAL**: Before assuming AWS credential issues, always test credentials first with `aws sts get-caller-identity`
155+
- **NEVER** assume credentials are incorrect without verification
156+
- If credentials test passes but .NET SDK fails, investigate SDK-specific credential chain issues
157+
- Common .NET SDK credential issues: EC2 instance metadata service conflicts, credential provider chain order
158+
159+
### Build Troubleshooting
160+
161+
#### DotNetV4 Build Troubleshooting
162+
- **CRITICAL**: When you get a response that the project file does not exist, use `listDirectory` to find the correct project/solution file path before trying to build again
163+
- **NEVER** repeatedly attempt the same build command without first locating the actual file structure
164+
- Always verify file existence with directory listing before executing build commands
165+
166+
### Language-Specific Pattern Errors to Avoid
167+
-**NEVER create examples for dotnetv3 UNLESS explicitly instructed to by the user**
168+
-**NEVER use camelCase for .NET class or method names**
169+
-**NEVER forget to dispose AWS clients (use using statements)**
170+
-**NEVER ignore proper exception handling for AWS operations**
171+
-**NEVER skip NuGet package management**
172+
-**NEVER assume credentials without testing first**
173+
-**NEVER use other language folders for patterns**
174+
175+
### Best Practices
176+
-**ALWAYS create examples in the dotnetv4 directory unless instructed otherwise**
177+
-**ALWAYS follow the established .NET project structure**
178+
-**ALWAYS use PascalCase for .NET identifiers**
179+
-**ALWAYS use using statements for AWS client management**
180+
-**ALWAYS include proper exception handling for AWS service calls**
181+
-**ALWAYS test AWS credentials before assuming credential issues**
182+
-**ALWAYS include comprehensive XML documentation**
183+
-**ALWAYS use async/await patterns for AWS operations**
184+
-**ALWAYS use dependency injection for AWS services**
185+
-**ALWAYS create a separate class in the Actions project for the Hello example**
186+
-**ALWAYS add project files to the main solution file DotNetV4Examples.sln**
187+
-**ALWAYS put print statements in the action methods if possible**
188+
189+
### Project Configuration Requirements
190+
- **Target Framework**: Specify appropriate .NET version in .csproj
191+
- **AWS SDK packages**: Include specific AWS service NuGet packages
192+
- **Test packages**: Include xUnit and test runner packages
193+
- **Configuration**: Support for appsettings.json and environment variables
194+
195+
### Integration with Knowledge Base
196+
Before creating .NET code examples:
197+
1. Query `coding-standards-KB` for "DotNet-code-example-standards"
198+
2. Query `DotNet-premium-KB` for "DotNet implementation patterns"
199+
3. Follow KB-documented patterns for project structure and class organization
200+
4. Validate against existing .NET examples only after KB consultation

0 commit comments

Comments
 (0)