Skip to content

Commit f082467

Browse files
authored
Merge branch 'main' into support-cases-guardrails
2 parents 3e5e515 + 97a348e commit f082467

File tree

5 files changed

+40
-33
lines changed

5 files changed

+40
-33
lines changed

case-summarization/deploy/case-summarization.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Resources:
269269
description="Focus on the main elements of the conversation and highlight the proposed solutions. If no specific solution, skip this section."
270270
)
271271
actions: str = Field(
272-
description="Finish off with any action items or next steps highlighting ownership of actions or next steps."
272+
description="Finish off with any action items or next steps highlighting ownership of actions or next steps. If none, skip this section."
273273
)
274274
references: list[str] = Field(
275275
description=(
@@ -360,6 +360,7 @@ Resources:
360360
model_id = get_model_id()
361361
362362
llm_program = get_llm_program(communications, model_id, GUARDRAIL_ID, GUARDRAIL_VERSION, GUARDRAIL_TRACE)
363+
363364
try:
364365
case_data_content['Summary'] = llm_program().model_dump_json()
365366
except Exception as exc:
@@ -493,7 +494,7 @@ Resources:
493494
QueueEventSourceMapping:
494495
Type: AWS::Lambda::EventSourceMapping
495496
Properties:
496-
BatchSize: !Ref BatchSize # Process N messages at a time to avoid Bedrock Tootling
497+
BatchSize: !Ref BatchSize # Process N messages at a time to avoid Bedrock Throttling
497498
Enabled: true
498499
EventSourceArn: !GetAtt SummarizationQueue.Arn
499500
FunctionName: !Ref SummarizationLambda

case-summarization/utils/release.sh

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,9 @@
22
# shellcheck disable=SC2016,SC2086,SC2162
33
# This script can be used for release
44

5-
export AWS_REGION=us-east-1
6-
export STACK_SET_NAME=LayerBuckets
75
export CENTRAL_BUCKET=aws-managed-cost-intelligence-dashboards
86

9-
code_path=$(git rev-parse --show-toplevel)/data-collection/deploy
7+
code_path=$(git rev-parse --show-toplevel)/case-summarization/deploy
108

119
echo "sync to central bucket"
12-
aws s3 sync $code_path/ s3://$CENTRAL_BUCKET/cfn/data-collection/
13-
14-
15-
16-
aws cloudformation list-stack-instances \
17-
--stack-set-name $STACK_SET_NAME \
18-
--query 'Summaries[].[StackId,Region]' \
19-
--output text |
20-
while read stack_id region; do
21-
echo "sync to $region"
22-
bucket=$(aws cloudformation list-stack-resources --stack-name $stack_id \
23-
--query 'StackResourceSummaries[?LogicalResourceId == `LayerBucket`].PhysicalResourceId' \
24-
--region $region --output text)
25-
26-
aws s3 sync $code_path/ s3://$bucket/cfn/data-collection/ --delete
27-
done
28-
29-
echo 'Done'
10+
aws s3 sync $code_path/ s3://$CENTRAL_BUCKET/cfn/case-summarization/

data-collection/deploy/account-collector.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ Resources:
110110
111111
import boto3
112112
113-
ROLE_NAME = os.environ['ROLE_NAME']
114-
RESOURCE_PREFIX = os.environ['RESOURCE_PREFIX']
115-
MANAGEMENT_ACCOUNT_IDS = os.environ['MANAGEMENT_ACCOUNT_IDS']
116-
BUCKET = os.environ['BUCKET_NAME']
113+
ROLE_NAME = os.environ.get('ROLE_NAME')
114+
RESOURCE_PREFIX = os.environ.get('RESOURCE_PREFIX')
115+
MANAGEMENT_ACCOUNT_IDS = os.environ.get('MANAGEMENT_ACCOUNT_IDS')
116+
BUCKET = os.environ.get('BUCKET_NAME')
117117
PREDEF_ACCOUNT_LIST_KEY = os.environ.get('PREDEF_ACCOUNT_LIST_KEY')
118118
LINKED_ACCOUNT_LIST_KEY = os.environ.get('LINKED_ACCOUNT_LIST_KEY')
119119
PAYER_ACCOUNT_LIST_KEY = os.environ.get('PAYER_ACCOUNT_LIST_KEY')
@@ -185,14 +185,14 @@ Resources:
185185
defined_accounts, ext = get_defined_list(BUCKET, PREDEF_ACCOUNT_LIST_KEY)
186186
try:
187187
if defined_accounts:
188-
logger.info(f'Using defined account list found in s3://{BUCKET}/{PREDEF_ACCOUNT_LIST_KEY} instead of payer organization')
188+
logger.info(f'Using defined account list found in s3://{BUCKET}/{PREDEF_ACCOUNT_LIST_KEY}{ext} instead of payer organization')
189189
for account_data in defined_accounts:
190190
if ext == "json":
191191
account = json.loads(account_data)
192192
yield format_account(account['account_id'], account['account_name'], account['payer_id'])
193193
else:
194194
account = account_data.split(',')
195-
yield format_account(account[0], account[1], account[2])
195+
yield format_account(account[0].strip(), account[1].strip(), account[2].strip())
196196
else:
197197
logger.info('Using payer organization for the account list')
198198
excluded_accounts = get_from_bucket(BUCKET, EXCLUDED_ACCOUNT_LIST_KEY)
@@ -210,13 +210,13 @@ Resources:
210210
continue
211211
yield format_account(account.get('Id'), account.get('Name'), org_account['payer_id'])
212212
except Exception as exc: #pylint: disable=broad-exception-caught
213-
logger.error(f'{org_account}: {exc}')
213+
logger.error( f'{type(exc).__name__}: When trying to build linked account list. {exc} ')
214214
215215
def get_defined_list(bucket, key):
216216
s3 = boto3.client("s3")
217217
exts = [".json", ".csv"]
218218
for ext in exts:
219-
accts = get_from_bucket(bucket, key, s3)
219+
accts = get_from_bucket(bucket, key+ext, s3)
220220
if accts:
221221
return accts, ext
222222
logger.debug(f'Predefined account list not retrieved or not being used')

data-collection/deploy/deploy-in-linked-account.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ Resources:
238238
- "elasticache:DescribeCacheClusters"
239239
- "eks:ListClusters"
240240
- "eks:DescribeCluster"
241+
- "eks:ListNodegroups"
242+
- "eks:DescribeNodegroup"
241243
- "lambda:ListFunctions"
242244
Resource: "*" ## Policy is used for scanning of a wide range of resources
243245
Roles:
@@ -341,4 +343,4 @@ Resources:
341343
cfn_nag:
342344
rules_to_suppress:
343345
- id: W12
344-
reason: "Policy is used for scanning of a wide range of resources"
346+
reason: "Policy is used for scanning of a wide range of resources"

data-collection/deploy/module-inventory.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,15 +1142,38 @@ Resources:
11421142
)
11431143
.search("clusters")
11441144
):
1145+
# Get cluster details
11451146
cluster = client.describe_cluster(name=cluster_name)
1146-
yield {
1147+
cluster_data = {
11471148
"Arn": cluster["cluster"]["arn"],
11481149
"Name": cluster["cluster"]["name"],
11491150
"CreatedAt": datetime.strftime(
11501151
cluster["cluster"]["createdAt"].astimezone(tz=timezone.utc), "%Y-%m-%dT%H:%M:%SZ"
11511152
),
11521153
"Version": cluster["cluster"]["version"],
11531154
}
1155+
# Get node groups for the cluster
1156+
try:
1157+
node_groups = client.list_nodegroups(clusterName=cluster_name).get("nodegroups", [])
1158+
cluster_data["NodeGroups"] = []
1159+
for node_group in node_groups:
1160+
node_group_details = client.describe_nodegroup(clusterName=cluster_name, nodegroupName=node_group)
1161+
cluster_data["NodeGroups"].append({
1162+
"NodeGroupName": node_group_details["nodegroup"].get("nodegroupName"),
1163+
"NodeRole": node_group_details["nodegroup"].get("nodeRole"),
1164+
"InstanceTypes": node_group_details["nodegroup"].get("instanceTypes",[]),
1165+
"ScalingConfig": node_group_details["nodegroup"].get("scalingConfig",{}),
1166+
"Subnets": node_group_details["nodegroup"].get("subnets",[]),
1167+
"Status": node_group_details["nodegroup"].get("status","Unknown"),
1168+
"AMIType": node_group_details["nodegroup"].get("amiType","Unknown"),
1169+
"Version": node_group_details["nodegroup"].get("version","Unknown"),
1170+
"CreatedAt": datetime.strftime(
1171+
node_group_details["nodegroup"]["createdAt"].astimezone(tz=timezone.utc), "%Y-%m-%dT%H:%M:%SZ"
1172+
),
1173+
})
1174+
except Exception as ng_exc: # Catch node group-specific issues
1175+
logger.error(f"Error fetching node groups for {cluster_name} in {region}: {ng_exc}")
1176+
yield cluster_data
11541177
except Exception as exc: #pylint: disable=W0718
11551178
logger.error(f"Cannot get info from {account_id}/{region}: {type(exc)}-{exc}")
11561179
return []

0 commit comments

Comments
 (0)