diff --git a/web/packages/teleport/src/Discover/Database/EnrollRdsDatabase/SingleEnrollment.tsx b/web/packages/teleport/src/Discover/Database/EnrollRdsDatabase/SingleEnrollment.tsx
index 43dede55ed56d..f8d3fa315de5c 100644
--- a/web/packages/teleport/src/Discover/Database/EnrollRdsDatabase/SingleEnrollment.tsx
+++ b/web/packages/teleport/src/Discover/Database/EnrollRdsDatabase/SingleEnrollment.tsx
@@ -201,7 +201,7 @@ export function SingleEnrollment({
<>
{showTable && (
<>
- Select an RDS to enroll:
+ Select an RDS database to enroll:
{
+ const rules = expandSecurityGroupRules(sg.inboundRules);
return (
- setViewRulesSelection({ sg, ruleType: 'inbound' })
+ setViewRulesSelection({
+ name: sg.name,
+ rules: rules,
+ ruleType: 'inbound',
+ })
}
>
- View ({sg.inboundRules.length})
+ View ({rules.length})
|
);
@@ -120,15 +127,20 @@ export const SecurityGroupPicker = ({
altKey: 'outboundRules',
headerText: 'Outbound Rules',
render: sg => {
+ const rules = expandSecurityGroupRules(sg.outboundRules);
return (
- setViewRulesSelection({ sg, ruleType: 'outbound' })
+ setViewRulesSelection({
+ name: sg.name,
+ rules: rules,
+ ruleType: 'outbound',
+ })
}
>
- View ({sg.outboundRules.length})
+ View ({rules.length})
|
);
@@ -177,3 +189,39 @@ function CheckboxCell({
);
}
+
+type ExpandedSecurityGroupRule = {
+ // IPProtocol is the protocol used to describe the rule.
+ ipProtocol: string;
+ // FromPort is the inclusive start of the Port range for the Rule.
+ fromPort: string;
+ // ToPort is the inclusive end of the Port range for the Rule.
+ toPort: string;
+ // Source is IP range, security group ID, or prefix list that the rule applies to.
+ source: string;
+ // Description contains a small text describing the source.
+ description: string;
+};
+
+// expandSecurityGroupRule takes a security group rule in the compact form that
+// AWS API returns, wherein rules are grouped by port range, and expands the
+// rule into a list of rules that is not grouped by port range.
+// This is the same display format that the AWS console uses when you view a
+// security group's rules.
+function expandSecurityGroupRule(
+ rule: SecurityGroupRule
+): ExpandedSecurityGroupRule[] {
+ return rule.cidrs.map(source => ({
+ ipProtocol: rule.ipProtocol,
+ fromPort: rule.fromPort,
+ toPort: rule.toPort,
+ source: source.cidr,
+ description: source.description,
+ }));
+}
+
+function expandSecurityGroupRules(
+ rules: SecurityGroupRule[]
+): ExpandedSecurityGroupRule[] {
+ return rules.flatMap(rule => expandSecurityGroupRule(rule));
+}
diff --git a/web/packages/teleport/src/Discover/Shared/SecurityGroupPicker/SecurityGroupRulesDialog.tsx b/web/packages/teleport/src/Discover/Shared/SecurityGroupPicker/SecurityGroupRulesDialog.tsx
index b86ce2e306129..6ee24d7e1a8d6 100644
--- a/web/packages/teleport/src/Discover/Shared/SecurityGroupPicker/SecurityGroupRulesDialog.tsx
+++ b/web/packages/teleport/src/Discover/Shared/SecurityGroupPicker/SecurityGroupRulesDialog.tsx
@@ -32,8 +32,7 @@ export function SecurityGroupRulesDialog({
viewRulesSelection: ViewRulesSelection;
onClose: () => void;
}) {
- const { ruleType, sg } = viewRulesSelection;
- const data = ruleType === 'inbound' ? sg.inboundRules : sg.outboundRules;
+ const { name, rules, ruleType } = viewRulesSelection;
return (