Skip to content

Commit 0152e70

Browse files
committed
Update for v5 Landing Zones.
1 parent 195382f commit 0152e70

4 files changed

Lines changed: 41 additions & 38 deletions

File tree

dotnetv4/ControlTower/Actions/ControlTowerWrapper.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,21 @@ public async Task<List<EnabledBaselineSummary>> ListEnabledBaselinesAsync()
125125
/// <param name="baselineIdentifier">The identifier of baseline to enable.</param>
126126
/// <param name="baselineVersion">The version of baseline to enable.</param>
127127
/// <param name="identityCenterBaseline">The identifier of identity center baseline if it is enabled.</param>
128-
/// <returns>The enabled baseline ARN or null if already enabled.</returns>
128+
/// <returns>The enabled baseline ARN or null.</returns>
129129
public async Task<string?> EnableBaselineAsync(string targetIdentifier, string baselineIdentifier, string baselineVersion, string identityCenterBaseline)
130130
{
131131
try
132132
{
133-
var parameters = new List<EnabledBaselineParameter>
133+
var parameters = new List<EnabledBaselineParameter>();
134+
if (!string.IsNullOrEmpty(identityCenterBaseline))
134135
{
135-
new EnabledBaselineParameter
136-
{
137-
Key = "IdentityCenterEnabledBaselineArn",
138-
Value = identityCenterBaseline
139-
}
140-
};
141-
136+
parameters.Add(
137+
new EnabledBaselineParameter
138+
{
139+
Key = "IdentityCenterEnabledBaselineArn",
140+
Value = identityCenterBaseline
141+
});
142+
}
142143
var request = new EnableBaselineRequest
143144
{
144145
BaselineIdentifier = baselineIdentifier,
@@ -164,9 +165,12 @@ public async Task<List<EnabledBaselineSummary>> ListEnabledBaselinesAsync()
164165

165166
return response.Arn;
166167
}
167-
catch (ValidationException ex) when (ex.Message.Contains("already enabled"))
168+
catch (ValidationException ex)
168169
{
169-
Console.WriteLine("Baseline is already enabled for this target");
170+
if (ex.Message.Contains("already enabled"))
171+
Console.WriteLine("Baseline is already enabled for this target");
172+
else { Console.WriteLine(ex.Message); }
173+
// Write the message and return null if baseline cannot be enabled.
170174
return null;
171175
}
172176
catch (AmazonControlTowerException ex)

dotnetv4/ControlTower/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@ For prerequisites, see the [README](../README.md#Prerequisites) in the `dotnetv4
3131

3232
### Get started
3333

34-
- [Hello AWS Control Tower](../ControlTower/Actions/HelloControlTower.cs#L4) (`ListBaselines`)
34+
- [Hello AWS Control Tower](Actions/HelloControlTower.cs#L4) (`ListBaselines`)
3535

3636

3737
### Basics
3838

3939
Code examples that show you how to perform the essential operations within a service.
4040

41-
- [Learn the basics](../ControlTower/Scenarios/ControlTower_Basics/ControlTowerBasics.cs)
41+
- [Learn the basics](Scenarios/ControlTower_Basics/ControlTowerBasics.cs)
4242

4343

4444
### Single actions
4545

4646
Code excerpts that show you how to call individual service functions.
4747

48-
- [DisableBaseline](../ControlTower/Actions/ControlTowerWrapper.cs#L181)
49-
- [DisableControl](../ControlTower/Actions/ControlTowerWrapper.cs#L401)
50-
- [EnableBaseline](../ControlTower/Actions/ControlTowerWrapper.cs#L120)
51-
- [EnableControl](../ControlTower/Actions/ControlTowerWrapper.cs#L345)
52-
- [GetBaselineOperation](../ControlTower/Actions/ControlTowerWrapper.cs#L273)
53-
- [GetControlOperation](../ControlTower/Actions/ControlTowerWrapper.cs#L449)
54-
- [ListBaselines](../ControlTower/Actions/ControlTowerWrapper.cs#L62)
55-
- [ListEnabledBaselines](../ControlTower/Actions/ControlTowerWrapper.cs#L91)
56-
- [ListEnabledControls](../ControlTower/Actions/ControlTowerWrapper.cs#L305)
57-
- [ListLandingZones](../ControlTower/Actions/ControlTowerWrapper.cs#L33)
58-
- [ResetEnabledBaseline](../ControlTower/Actions/ControlTowerWrapper.cs#L227)
48+
- [DisableBaseline](Actions/ControlTowerWrapper.cs#L185)
49+
- [DisableControl](Actions/ControlTowerWrapper.cs#L405)
50+
- [EnableBaseline](Actions/ControlTowerWrapper.cs#L120)
51+
- [EnableControl](Actions/ControlTowerWrapper.cs#L349)
52+
- [GetBaselineOperation](Actions/ControlTowerWrapper.cs#L277)
53+
- [GetControlOperation](Actions/ControlTowerWrapper.cs#L453)
54+
- [ListBaselines](Actions/ControlTowerWrapper.cs#L62)
55+
- [ListEnabledBaselines](Actions/ControlTowerWrapper.cs#L91)
56+
- [ListEnabledControls](Actions/ControlTowerWrapper.cs#L309)
57+
- [ListLandingZones](Actions/ControlTowerWrapper.cs#L33)
58+
- [ResetEnabledBaseline](Actions/ControlTowerWrapper.cs#L231)
5959

6060

6161
<!--custom.examples.start-->

dotnetv4/ControlTower/Scenarios/ControlTower_Basics/ControlTowerBasics.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static async Task RunScenario()
130130
Console.WriteLine("\nEnabling Control Tower Baseline.");
131131
var icBaselineArn = identityCenterBaseline?.Arn;
132132
baselineArn = await wrapper.EnableBaselineAsync(ouArn,
133-
controlTowerBaseline.Arn, "4.0", icBaselineArn ?? "");
133+
controlTowerBaseline.Arn, "5.0", icBaselineArn ?? "");
134134
var alreadyEnabled = false;
135135
if (baselineArn != null)
136136
{
@@ -144,12 +144,11 @@ public static async Task RunScenario()
144144
if (enabled.BaselineIdentifier == controlTowerBaseline.Arn)
145145
{
146146
baselineArn = enabled.Arn;
147+
alreadyEnabled = true;
148+
Console.WriteLine("No change, the selected baseline was already enabled.");
147149
break;
148150
}
149151
}
150-
151-
alreadyEnabled = true;
152-
Console.WriteLine("No change, the selected baseline was already enabled.");
153152
}
154153

155154
if (baselineArn != null)
@@ -173,7 +172,7 @@ public static async Task RunScenario()
173172
Console.WriteLine($"\nRe-enabling Control Tower Baseline: {baselineArn}");
174173
// Re-enable the Control Tower baseline if it was originally enabled.
175174
await wrapper.EnableBaselineAsync(ouArn,
176-
controlTowerBaseline.Arn, "4.0", icBaselineArn ?? "");
175+
controlTowerBaseline.Arn, "5.0", icBaselineArn ?? "");
177176
}
178177
}
179178
}

python/example_code/controltower/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ Code examples that show you how to perform the essential operations within a ser
5252

5353
Code excerpts that show you how to call individual service functions.
5454

55-
- [DisableBaseline](controltower_wrapper.py#L392)
56-
- [DisableControl](controltower_wrapper.py#L263)
55+
- [DisableBaseline](controltower_wrapper.py#L396)
56+
- [DisableControl](controltower_wrapper.py#L267)
5757
- [EnableBaseline](controltower_wrapper.py#L69)
58-
- [EnableControl](controltower_wrapper.py#L159)
59-
- [GetBaselineOperation](controltower_wrapper.py#L236)
60-
- [GetControlOperation](controltower_wrapper.py#L209)
58+
- [EnableControl](controltower_wrapper.py#L163)
59+
- [GetBaselineOperation](controltower_wrapper.py#L240)
60+
- [GetControlOperation](controltower_wrapper.py#L213)
6161
- [ListBaselines](controltower_wrapper.py#L39)
62-
- [ListEnabledBaselines](controltower_wrapper.py#L330)
63-
- [ListEnabledControls](controltower_wrapper.py#L431)
64-
- [ListLandingZones](controltower_wrapper.py#L300)
65-
- [ResetEnabledBaseline](controltower_wrapper.py#L358)
62+
- [ListEnabledBaselines](controltower_wrapper.py#L334)
63+
- [ListEnabledControls](controltower_wrapper.py#L435)
64+
- [ListLandingZones](controltower_wrapper.py#L304)
65+
- [ResetEnabledBaseline](controltower_wrapper.py#L362)
6666

6767

6868
<!--custom.examples.start-->

0 commit comments

Comments
 (0)