Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
austinsonger committed Jun 19, 2024
1 parent 436b6a1 commit 9154fd2
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions services/providers/hosting/rules/aws/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
## Template

```
from aws_cdk import core
import boto3
class InfoRetrievalStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, info_function, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# Initialize a boto3 session
session = boto3.Session()
client = session.client('service_name') # Replace 'service_name' with the desired AWS service
# Retrieve information from the AWS service
response = client.describe_something() # Replace 'describe_something' with the desired method call
# Call the info_function with the client and response data
info_function(client, response)
def example_info_function(client, response):
# Example function to process response data
# Replace this with your custom logic
print(response)
app = core.App()
# Initialize stack with the example function
InfoRetrievalStack(app, "InfoRetrievalStack", example_info_function)
app.synth()
```

### Explanation:

1. **InfoRetrievalStack Class**: This is the main stack class. It initializes a boto3 session and a generic AWS client, retrieves information from the specified AWS service, and calls a user-defined function (`info_function`) to process the response data.
2. **info_function Parameter**: This parameter allows you to pass any function that takes `client` and `response` as arguments and performs specific operations.
3. **example_info_function**: This is a placeholder function to demonstrate how you can process the retrieved data. You can replace this with your custom function to perform the desired operations.
4. **App Initialization**: In the `app` initialization section, the `InfoRetrievalStack` is created, and the `example_info_function` is passed as the `info_function` argument. You can replace `example_info_function` with your custom function.

### Usage:

- **Define Custom Functions**: Replace `example_info_function` with your custom function that processes the AWS service response data in the way you need.
- **Specify AWS Service and Method**: Replace `'service_name'` with the desired AWS service (e.g., `ec2`, `s3`, etc.) and `describe_something` with the method call you want to use (e.g., `describe_instances`, `list_buckets`, etc.).
- **Create Multiple Stacks**: You can create multiple instances of `InfoRetrievalStack` with different functions to retrieve various types of information.
- **Deploy**: Run `cdk deploy` to deploy your stack.

This template provides a minimal starting point with placeholders, making it flexible and easy to adapt for different AWS services and data retrieval requirements.

0 comments on commit 9154fd2

Please sign in to comment.