SCS-C03 · Domain 6 · Security Foundations and Governance (14%) · Day 2 of 3
Secure, consistent deployment across accounts
On Day 1 you built the account structure with Organizations, Control Tower, SCPs and RCPs. Today you fill those accounts the same secure way every time: CloudFormation StackSets, policy as code with cfn-lint, Guard and Hooks, a tagging strategy with tag policies and SCPs, central firewall rules with Firewall Manager, and sharing with Service Catalog and AWS RAM.
Skill 6.2.1 infrastructure as codeSkill 6.2.2 tagsSkill 6.2.3 central policy enforcementSkill 6.2.4 secure resource sharing~90 min read + 30 min lab
01
CloudFormation StackSets across accounts
Yesterday you built the account structure with Organizations and Control Tower. Today you fill those accounts with the same secure resources, every time. Skill 6.2.1 is about infrastructure as code (IaC): you describe resources in a template and let a tool create them. When one template must reach many accounts and Regions, the AWS answer is CloudFormation StackSets.
A StackSet is one template plus parameters. Each copy that lands in one account and one Region is a stack instance. Typical uses are security baselines: a CloudTrail trail, a GuardDuty setting, an IAM role for the security team, an AWS Config rule, or an S3 bucket policy.
Concept profile
CloudFormation StackSets
often confused with a single CloudFormation stack
?What is it?
A CloudFormation feature that creates, updates or deletes stacks across many accounts and Regions with one operation, from one administrator account.
⚙How does it work?
Service-managed permissions: needs Organizations with all features and trusted access turned on. CloudFormation creates the roles for you. You target OUs (or the whole organization). The management account or a delegated administrator (up to five) runs it.
Automatic deployment (service-managed only): when an account joins a target OU, CloudFormation deploys the stack to it. When an account leaves, it deletes the stack or retains it (RetainStacksOnAccountRemoval).
Self-managed permissions: you create AWSCloudFormationStackSetAdministrationRole in the administrator account and AWSCloudFormationStackSetExecutionRole in each target account. You target account IDs. Works without Organizations.
Deployment options: maximum concurrent accounts, failure tolerance (per Region), and Region concurrency (sequential by default, or parallel).
{ }Structure
One StackSet, many stack instances. New accounts in a target OU get the stack automatically.
⇄StackSets vs a single CloudFormation stack
StackSets
Single stack
Reach
Many accounts × many Regions
One account, one Region
New accounts
Automatic deployment (service-managed)
Someone must deploy by hand
Permissions
Service-managed or self-managed roles
Your own credentials or a service role
Drift
Per stack instance, rolled up to the StackSet
Per stack
Exam hint
“every account”, “new accounts automatically”
“one workload”
!Common mistakes the exam tests
Expecting a service-managed StackSet to deploy into the management account: it doesn’t, even when you target the root. Use a normal stack there.
Choosing self-managed permissions and expecting automatic deployment to new accounts: that needs service-managed permissions.
Misspelling the execution role: self-managed StackSets look for the exact role name in each target account.
Trying service-managed StackSets in an organization with only consolidated billing features: it needs all features.
Setting failure tolerance to 0 and max concurrency high: one failure stops the rollout, but many accounts may already have changed.
✓Benefits and use cases
Security baseline (roles, trails, Config rules) in every account.
Same resources in many Regions, for example a KMS key or alarm.
Customizations on top of Control Tower landing zones.
Drift detection and stack policies
IaC only stays secure if people don’t change resources by hand. Drift detection compares the real resources with the template. A resource is MODIFIED or DELETED; a stack is DRIFTED or IN_SYNC; a StackSet is drifted if any stack instance has drifted. Drift detection is an operation you start (or schedule yourself, for example from EventBridge or an AWS Config rule); it only reports and never fixes anything. It checks only properties that are set in the template and doesn’t include nested stacks. A stack policy protects resources from updates: once you set one, every resource is protected unless an Allow statement says otherwise, and Deny always wins. You can’t delete a stack policy, only replace it, and you can pass a temporary override policy for one update. Stack policies don’t stop stack deletion; turn on termination protection for that.
Think of it like · a franchise opening new shops
Head office keeps every shop the same.
AWS concept
Familiar thing
StackSet
≈
The franchise manual that every shop must follow
Stack instance
≈
One shop in one city that was built from the manual
Automatic deployment
≈
A new shop opening in the region gets the full fit-out on day one
Retain stacks
≈
A shop leaves the franchise but keeps its furniture
Drift detection
≈
An inspector who notices a manager repainted the walls
Stack policy
≈
A sign on the safe: ‘do not replace without head office approval’
Real AWS example · service-managed StackSet with automatic deployment
Create the StackSet, then deploy it to two OUs in two Regions.
Run these from the management account or a delegated administrator (add --call-as DELEGATED_ADMIN).
Exam-style scenario
A company has 60 accounts in AWS Organizations and adds about five accounts each month. Every account in the Workloads OU must get an IAM role for the security team and an AWS Config rule as soon as it is created, with no manual work. What should a security engineer do?
A. Create a StackSet with self-managed permissions and add each new account ID every month.
B. Create a StackSet with service-managed permissions targeting the Workloads OU, with automatic deployment enabled.
C. Write a Lambda function that runs CreateStack in each new account.
D. Ask each account owner to deploy the template.
Show the worked answer
Answer: B
Service-managed StackSets deploy automatically to accounts that join the target OU.
Why not the others
A: Self-managed StackSets don’t support automatic deployment; it is manual work.
C: Custom code to maintain, when a built-in feature exists.
D: Not consistent and not automatic.
How the exam tests this
“Deploy to all current and future accounts in an OU”→ Service-managed StackSet + automatic deployment.
“No Organizations, a few known accounts”→ Self-managed StackSet with admin + execution roles.
“Let the security account run StackSets”→ Register it as a delegated administrator.
“Find manual console changes to stack resources”→ Drift detection.
“Stop updates that replace the production database”→ Stack policy denying Update:Replace.
Must remember
Service-managed = OUs, auto-deploy, roles made for you.
Self-managed = account IDs + two roles with exact names.
Management account never gets a service-managed instance.
Drift detection reports, never fixes.
Stack policy: everything protected once set; Deny wins; can’t delete it.
StackSets copy a template everywhere, so a mistake in the template is copied everywhere too. Skill 6.2.1 names two tools to catch mistakes before deployment: cfn-lint and CloudFormation Guard. AWS adds a third layer inside CloudFormation itself: CloudFormation Hooks. This idea is called shift left: find the problem as early, and as cheaply, as possible.
Concept profile
AWS CloudFormation Guard
often confused with cfn-lint
?What is it?
An open-source, general-purpose policy-as-code tool. You write rules in a simple declarative domain-specific language (DSL), and Guard checks any JSON or YAML data against them.
⚙How does it work?
Rules look like Resources.*[ Type == 'AWS::S3::Bucket' ].Properties.BucketEncryption exists.
cfn-guard validate checks data against rules; cfn-guard test runs unit tests for your rules; cfn-guard rulegen creates starter rules from an existing template.
Works on CloudFormation templates and change sets, JSON Terraform files (such as a plan exported as JSON), Kubernetes files and AWS Config configuration items.
Run it in the pipeline (CodeBuild, GitHub Actions) to fail a build, or use it as the logic inside a Guard Hook.
{ }Structure
Each layer catches a different kind of problem.
⇄Guard vs cfn-lint
Guard
cfn-lint
Question it answers
Does it follow our security rules?
Is it a valid CloudFormation template?
Rules
You write them (DSL)
Built in, from the resource specification
Input
Any JSON/YAML (CFN, Terraform JSON, K8s)
CloudFormation templates
Example finding
“Bucket has no encryption”
“Property BucketNme is not valid”
Server-side enforcement
Only through a Guard Hook
No
!Common mistakes the exam tests
Picking cfn-lint to enforce “all buckets must be encrypted”: lint checks validity and best practice, not your company policy. Use Guard.
Picking Guard to catch invalid property values or syntax: that is cfn-lint.
Thinking pipeline checks are enough: a developer can deploy from a laptop and skip the pipeline. Hooks run inside CloudFormation for every stack.
Forgetting Hooks have a warn mode: use it first to see what would fail, then switch to fail.
Expecting Guard or Hooks to find changes made later in the console: that is drift detection or AWS Config.
✓Benefits and use cases
Fail a pull request that opens port 22 to 0.0.0.0/0.
One rule set for CloudFormation and Terraform plans.
Block non-compliant stacks in every account with Hooks.
CloudFormation Hooks and third-party IaC
Hooks are checks that CloudFormation runs before it provisions resources. They can target resources, whole stacks, change sets and also resources created through the Cloud Control API. If a resource fails, the Hook either fails the operation or only emits a warning, depending on its failure mode. You can build Hooks from Guard rules, from Lambda functions, from custom code, or turn on AWS Control Tower proactive controls, which are ready-made Hooks. Remember the three Control Tower control behaviours from Day 1: preventive (SCPs and RCPs), detective (Config rules) and proactive (Hooks).
Third-party IaC such as Terraform or Pulumi is fine for the exam if you secure it: keep the Terraform state file in an encrypted, versioned S3 bucket with tight access (state can contain secrets), let the pipeline assume a role per account (for example with OIDC federation) instead of using long-term access keys, scan the plan with Guard or similar tools, and keep AWS Config rules as a detective safety net.
Think of it like · building a house
Several checks before people can move in.
AWS concept
Familiar thing
cfn-lint
≈
A spell checker for the architect’s drawings: wrong symbols, impossible sizes
Guard rules
≈
The city building code: smoke alarms and fire exits are required
Guard in CI
≈
The architect checks the code before sending the drawings
Hooks
≈
The city inspector at the site, who can stop the builders even if the architect skipped a check
Warn mode
≈
The inspector writes a note but lets work continue
Drift detection
≈
A later visit that finds the owner removed a wall
Real AWS example · a Guard rule and its result
The rule requires encryption and blocks public ACLs on every bucket.
# s3.guard
let buckets = Resources.*[ Type == 'AWS::S3::Bucket' ]
rule s3_encrypted when %buckets !empty {
%buckets.Properties.BucketEncryption exists
%buckets.Properties.PublicAccessBlockConfiguration.BlockPublicAcls == true
}
$ cfn-guard validate --data template.yaml --rules s3.guard
template.yaml Status = FAIL
FAILED rules
s3.guard/s3_encrypted FAIL
$ cfn-lint template.yaml
E3002 Additional properties are not allowed ('BucketNme' was unexpected)
template.yaml:12:7
The two tools found two different problems: Guard found a policy gap; cfn-lint found a typo.
Exam-style scenario
A company deploys infrastructure with CloudFormation from a CI/CD pipeline that runs cfn-guard. The security team found that some developers create stacks directly from their laptops, and those stacks contain security groups open to 0.0.0.0/0. The company wants to block these stacks in every account, whatever tool starts the deployment, using the existing Guard rules. What should it do?
A. Add cfn-lint to the pipeline.
B. Activate a CloudFormation Guard Hook with the existing rules in every account (for example with a StackSet), in fail mode.
C. Run drift detection every hour.
D. Remove the developers’ IAM permissions for EC2 only.
Show the worked answer
Answer: B
Hooks run inside CloudFormation before provisioning, so they apply even when the pipeline is skipped, and Guard Hooks reuse the same rules.
Why not the others
A: Still only in the pipeline, and lint checks validity, not policy.
C: Detects problems after they exist; doesn’t block.
D: CloudFormation could still create groups with the developer’s other permissions or a service role; it doesn’t target the real rule.
How the exam tests this
“Enforce company rules on templates in the pipeline”→ CloudFormation Guard.
“Check template syntax and valid property values”→ cfn-lint.
“Server-side check before provisioning, can’t be skipped”→ CloudFormation Hooks.
“Ready-made proactive controls across the organization”→ Control Tower proactive controls (as Hooks).
“Same policy checks for Terraform plans”→ Guard on the JSON plan.
Must remember
Lint = valid? Guard = compliant?
Guard: open source DSL, validate · test · rulegen.
Hooks: before provisioning, fail or warn.
Hooks from Guard, Lambda, custom, or Control Tower proactive controls.
Skill 6.2.2 is about tags: key and value labels such as Environment=prod. Tags let you group resources for cost reports, automation, incident response and access control (ABAC from the IAM days). They only help if everyone uses the same keys and every resource actually has them. Tag keys and values are case sensitive on the resource, so CostCenter and costcenter are two different tags. Careful: in an IAM or SCP condition, the tag key inside the key name (aws:RequestTag/CostCenter) is matched case-insensitively, while the value is compared exactly by StringEquals. To force one spelling of the key, use a tag policy that enforces capitalization or a Deny on aws:TagKeys.
Concept profile
Tag policies (AWS Organizations)
often confused with SCPs that require tags
?What is it?
An Organizations management policy type that standardises tags: which key names to use, their capitalisation, and which values are allowed, across all accounts it is attached to.
⚙How does it work?
Needs Organizations with all features; attach to the root, OUs or accounts, and policies inherit down the tree.
Without enforcement, a tag policy only reports non-compliant tags.
Add enforced_for with resource types (for example ec2:instance) to block non-compliant tagging operations on those types.
Untagged resources are not evaluated: a tag policy can’t force a tag to exist.
See compliance with Resource Groups (Tag Editor); from the management account you see all accounts.
{ }Structure
Three tools, three jobs.
⇄Tag policies vs SCPs that require tags
Tag policy
SCP with aws:RequestTag
Main job
Same key spelling and allowed values
Tag must be present when creating
Untagged resource
Not evaluated, allowed
Create call denied
Wrong value
Blocked only with enforced_for
Blocked if the condition checks values
Reporting
Compliance report
None (just AccessDenied)
Exam hint
“standardise”, “consistent case”
“must not create without the tag”
!Common mistakes the exam tests
Using a tag policy to stop people creating untagged resources: tag policies ignore untagged resources. Use an SCP with a Null condition on aws:RequestTag/CostCenter.
Writing the SCP on the wrong resource: for EC2 the tag check belongs on ec2:RunInstances for the instance (and volume) resource, not on the AMI or subnet.
Forgetting to stop people changing or deleting tags later, which breaks ABAC: deny ec2:CreateTags/DeleteTags on protected keys with aws:TagKeys.
Expecting user-defined tags in cost reports immediately: they must be activated as cost allocation tags in Billing.
Enforcing a new tag policy everywhere at once: test it on one account first, as AWS recommends.
✓Benefits and use cases
Show cost per department or cost center.
Find every production resource during an incident.
ABAC: allow access only when principal and resource tags match.
A simple tagging strategy
Start with a short list of mandatory keys, for example Department, CostCenter, Environment (prod, staging, dev), Owner and DataClassification. Write them down with the exact spelling and allowed values. Then: put the rules in a tag policy, require the most important keys at creation with an SCP, apply default tags in IaC (StackSets, Service Catalog TagOptions, Terraform default tags), and use AWS Resource Groups to build tag-based groups that tools like Systems Manager can act on. AWS Config’s required-tags rule is a detective check for anything that slipped through.
Think of it like · a school uniform
How a school keeps every pupil easy to identify.
AWS concept
Familiar thing
Tagging strategy
≈
The uniform rules written in the school handbook
Tag policy
≈
The handbook says the badge must read ‘Year 9’, not ‘yr9’
enforced_for
≈
The shop refuses to sell a badge with the wrong spelling
SCP + aws:RequestTag
≈
The gate guard won’t let anyone in without a name badge
Resource Groups
≈
Calling all pupils with a red badge to the hall
Cost allocation tag
≈
Sending the bill for each class trip to the right parents
Real AWS example · SCP: no EC2 instance without a CostCenter tag
Denies the launch when the request has no CostCenter tag.
Together: the SCP makes the tag required; the tag policy makes the spelling and value correct.
Exam-style scenario
A finance team says cost reports are useless because resources are tagged “costcenter”, “Cost-Center” and “CostCenter”, and many EC2 instances have no cost tag at all. The company uses AWS Organizations with all features. Which combination fixes both problems with the least effort?
A. An AWS Config rule in each account that emails owners.
B. A tag policy that defines the CostCenter key and allowed values, enforced for ec2:instance, plus an SCP that denies ec2:RunInstances when aws:RequestTag/CostCenter is null.
C. A tag policy only, enforced for all resource types.
D. IAM permission boundaries on every developer role.
Show the worked answer
Answer: B
The tag policy fixes spelling and values; the SCP stops untagged launches, which tag policies don’t evaluate.
Why not the others
A: Detects but doesn’t prevent, and must be built per account.
C: Tag policies don’t evaluate untagged resources, so instances without the tag still launch.
D: Boundaries limit permissions per role; much more work and not a tagging standard.
How the exam tests this
“Standardise tag key case and values across the org”→ Tag policy.
“Prevent creating resources without a required tag”→ SCP with aws:RequestTag + Null.
“Stop users removing the Owner tag”→ Deny tag actions with aws:TagKeys.
“View non-compliant tags across all accounts”→ Resource Groups compliance from the management account.
“Group resources by tag for operations”→ AWS Resource Groups.
Must remember
Tags are case sensitive on resources; condition key names are not.
Tag policy: spelling + values; untagged not checked.
Skill 6.2.3 says deploy and enforce policies and configurations from a central source, and the example is AWS Firewall Manager. On Infrastructure Day 1 you met it as the way to roll out WAF and Shield Advanced. Here you need the full picture: its prerequisites, all its policy types, and how scope and auto-remediation work.
Concept profile
AWS Firewall Manager
often confused with AWS Config rules / StackSets
?What is it?
A security management service that applies firewall policies across all accounts and resources in AWS Organizations from one administrator account, and keeps applying them to new accounts and resources.
⚙How does it work?
Prerequisites, in order: join AWS Organizations (all features); set the Firewall Manager administrator account from the management account (you can add more administrators with a limited scope); enable AWS Config in each member account and Region in scope; for Network Firewall and DNS Firewall policies, enable AWS RAM sharing with the organization; for third-party firewalls, subscribe in AWS Marketplace.
Policy types: AWS WAF, Shield Advanced, VPC security group, VPC network ACL, Network Firewall, Route 53 Resolver DNS Firewall and third-party firewalls (Palo Alto Cloud NGFW, Fortigate CNF). Each policy has one type.
Scope: include or exclude accounts and OUs, choose resource types, and include or exclude by tag.
Choose auto-remediation on (fix non-compliant resources) or off (only report).
{ }Structure
Set up once, then every in-scope account follows the policy.
⇄Firewall Manager vs AWS Config rules / StackSets
Firewall Manager
Config rules / StackSets
Scope
Firewall resources (WAF, SG, NACL, NFW, DNS FW…)
Any resource / any template
New accounts
Policy applied automatically
Conformance packs / auto-deploy can do it too
Keeps checking
Yes, finds and fixes non-compliance
Config: yes; StackSets: only on deploy (+ drift)
Local rules allowed
Yes, between central first/last rules
n/a
Exam hint
“central firewall rules in all accounts”
“deploy any baseline”, “check any setting”
!Common mistakes the exam tests
Forgetting AWS Config: Firewall Manager can’t see or fix resources in accounts where Config isn’t recording.
Expecting Network Firewall or DNS Firewall policies to work without RAM sharing enabled for the organization.
Turning on auto-remediation for a security group audit policy on day one: AWS recommends starting with remediation off and reviewing the findings, because remediation can change or delete groups.
Thinking one policy can mix types: create one policy per type.
Letting another tool manage the same security groups: the two tools keep undoing each other. Exclude one from the other by tags.
✓Benefits and use cases
Same WAF rule groups on every public ALB and CloudFront distribution.
Remove SSH from 0.0.0.0/0 everywhere.
Network Firewall and DNS Firewall in every new VPC.
Security group, Network Firewall and DNS Firewall policies
Security group policies come in three kinds. A common policy pushes a standard security group (for example “allow HTTPS from the corporate range”) to in-scope resources, such as EC2 instances and ALBs selected by tag. A content audit policy checks the rules inside groups and flags or removes forbidden ones, such as SSH from 0.0.0.0/0. A usage audit policy finds and cleans up unused or redundant groups. Changes to groups on EC2 network interfaces can take up to six hours to show in Firewall Manager. A Network Firewall policy creates firewall endpoints in in-scope VPCs with a central firewall policy, in a distributed model (one firewall per VPC) or a centralized inspection VPC. A DNS Firewall policy associates Route 53 Resolver DNS Firewall rule groups with VPCs to block lookups of bad domains. Like WAF policies, it uses central rule groups that run first and last, and account teams may add their own in between. A network ACL policy enforces baseline NACL rules on subnets.
Think of it like · a hotel chain’s safety office
One office sets safety rules for every hotel.
AWS concept
Familiar thing
Firewall Manager
≈
Head office safety team for all hotels in the chain
AWS Config prerequisite
≈
CCTV in each hotel: without it head office can’t see anything
Common SG policy
≈
Every room door gets the same standard lock
Content audit
≈
Inspectors check that no fire door is propped open
Usage audit
≈
Removing old locks from rooms nobody uses
First / last rule groups
≈
Head office rules start and end every safety checklist; each hotel adds its own in the middle
Real AWS example · a content audit security group policy
Audit every security group in the Workloads OU and flag rules that allow SSH from anywhere. Remediation stays off at first.
The audit group sg-0audit lists the rules that are allowed; anything outside it is a violation.
Exam-style scenario
A company with 80 accounts wants to block DNS queries to known malware domains from every VPC, including VPCs created later in new accounts. Account teams must be able to add their own domain block lists. AWS Config is enabled everywhere. What else must the security team do?
A. Create a DNS Firewall rule group in each account manually.
B. Enable AWS RAM sharing with the organization, then create a Firewall Manager DNS Firewall policy with the central rule group as a first rule group.
C. Use GuardDuty to block DNS queries.
D. Deploy Network ACLs that block the malware IPs.
Show the worked answer
Answer: B
Firewall Manager DNS Firewall policies need RAM sharing enabled; they reach new VPCs automatically and let accounts add rule groups between first and last.
Why not the others
A: Manual and misses new VPCs.
C: GuardDuty detects; it doesn’t block DNS queries.
D: NACLs work on IPs, not domain names, and change constantly.
How the exam tests this
“Same firewall rules in all accounts, new ones too”→ Firewall Manager.
“Firewall Manager can’t see member accounts”→ Enable AWS Config there.
“DNS Firewall / Network Firewall policy fails to deploy”→ Enable RAM sharing with Organizations.
“Remove unused security groups org-wide”→ Usage audit SG policy.
“Flag SSH open to the world everywhere”→ Content audit SG policy.
Must remember
Prereqs: Organizations · admin · Config · RAM.
Seven types: WAF, Shield, SG, NACL, NFW, DNS FW, third-party.
Skill 6.2.4 is about securely sharing resources across accounts. The first example is AWS Service Catalog: instead of giving teams broad permissions to build things themselves, a central team offers a menu of approved, secure products. Teams launch them with a click, and the product is always built the approved way.
Concept profile
AWS Service Catalog portfolios and products
often confused with AWS RAM
?What is it?
A service where administrators publish approved IaC templates as products, group them in portfolios, control who may use them, and let end users launch them without broad permissions.
⚙How does it work?
A product is a versioned CloudFormation template (or a Terraform configuration). A portfolio holds products, constraints and the IAM principals who can use it.
A launch constraint names the IAM role that Service Catalog assumes to launch, update or terminate the product, so end users only need Service Catalog permissions. It applies to one product in one portfolio.
Other constraints: template constraints (limit parameter values, such as instance types), notification, tag update and StackSet constraints. TagOptions apply standard tags.
Share portfolios account to account (the recipient imports it) or through AWS Organizations to an OU or account (no import needed).
{ }Structure
A hub and spoke model: build once centrally, launch safely everywhere.
Giving end users full EC2 and CloudFormation rights so they can launch products: use a launch constraint role instead.
Using a full role ARN in the launch constraint of a shared portfolio: the ARN belongs to one account. Use a role name that exists in every recipient account.
Expecting recipients to edit shared products or constraints: they can only add IAM principals and local TagOptions.
Trying to re-share an imported portfolio: you can’t share a shared resource.
Mixing up portfolios and products: access is granted on the portfolio.
✓Benefits and use cases
Self-service for developers within guardrails.
Only approved instance types and encrypted storage.
One central team updates a product version; all accounts see it.
Sharing portfolios safely
When you share a portfolio you share a reference: the products and constraints stay in sync with your changes. The recipient administrator decides which of their users get access. With Organizations sharing you can also share principal names (role names that are matched in each account) and TagOptions. AWS recommends the IAM principal type rather than a pattern that could match roles created later, to avoid a privilege escalation path. Service Catalog AppRegistry is a related feature that records your applications and their resources.
Think of it like · a company canteen
Staff get good food without entering the kitchen.
AWS concept
Familiar thing
Product
≈
One dish on the menu, cooked by a fixed recipe
Product version
≈
A new edition of the recipe
Portfolio
≈
The menu for one floor of the building
Launch constraint
≈
Only the cook goes into the kitchen; you just order
Template constraint
≈
You can choose small or medium, not extra large
Sharing a portfolio
≈
Other office buildings get the same menu, updated centrally
Real AWS example · launch constraint and Organizations share
Use a role name so the constraint works in every account, then share with an OU.
Deploy the SCLaunch-S3Product role to every account first, for example with a StackSet.
Exam-style scenario
Developers in 30 accounts need to create S3 buckets that are always encrypted with KMS and block public access. The security team doesn’t want to give developers s3:CreateBucket or CloudFormation permissions. Which solution meets these requirements?
A. Share an S3 bucket with AWS RAM.
B. Create a Service Catalog product for the secure bucket, add a launch constraint with a local role name, and share the portfolio to the developers’ OU through AWS Organizations.
C. Give developers PowerUserAccess and an SCP that requires encryption.
D. Email the CloudFormation template to each team.
Show the worked answer
Answer: B
The launch role creates the bucket, so developers need only Service Catalog permissions, and the product always builds the approved configuration.
Why not the others
A: S3 buckets aren’t shared with RAM, and they need their own buckets.
C: Gives far more permission than needed.
D: Teams could change the template and need CloudFormation rights.
How the exam tests this
“Self-service launch of approved resources”→ Service Catalog.
“End users must not need permissions for underlying services”→ Launch constraint role.
“Limit instance types users can choose”→ Template constraint.
“Share a portfolio with an OU without imports”→ Organizations portfolio sharing.
“Launch role must work in many accounts”→ Local role name in the launch constraint.
Service Catalog shares recipes. AWS RAM shares the actual resource. One network team can own a VPC subnet, a Transit Gateway or a Route 53 Resolver rule, and many accounts can use it. This avoids building the same thing in every account and keeps control with one owner.
Concept profile
AWS Resource Access Manager
often confused with resource-based policies
?What is it?
A service that shares supported resources you own with other accounts, OUs, your whole organization, and for some types IAM roles, users or service principals.
⚙How does it work?
A resource share has three parts: the resources, the principals, and a managed permission for each resource type that says what principals may do.
To share inside your organization, first run enable-sharing-with-aws-organization in RAM from the management account. Then principals in the org get access without invitations.
Principals outside the organization get an invitation and have access only after they accept. A share must allow external principals for this.
AWS managed permissions cover normal use; customer managed permissions let you allow fewer actions for least privilege. Only the default version of a permission can be attached.
{ }Structure
Inside the org: automatic. Outside: invitation, and only if allowed.
⇄RAM vs resource-based policies
RAM
Resource-based policies
Used by
Subnets, TGWs, Resolver rules, prefix lists, Private CA, IPAM pools…
S3, KMS, SQS, SNS, Lambda, Secrets Manager…
Share with whole org/OU
Yes, by org or OU ARN
With aws:PrincipalOrgID / PrincipalOrgPaths conditions
Where defined
A resource share in RAM
A policy on the resource itself
Permissions
Managed permissions
The policy statements
Exam hint
“share a subnet / Transit Gateway”
“cross-account access to a bucket or key”
!Common mistakes the exam tests
Turning on trusted access from the Organizations console and expecting org sharing to work: enable sharing in RAM (console Settings or CLI), which creates the needed service-linked role.
Sharing a VPC subnet with an account outside the organization: subnets can be shared only within the same organization.
Expecting participants to change a shared subnet or Transit Gateway: the owner keeps control and cost; participants only use it.
Leaving “allow sharing with anyone” open: restrict with an SCP that denies ram:CreateResourceShare and ram:UpdateResourceShare when ram:RequestedAllowsExternalPrincipals is true.
Using RAM for S3 buckets or KMS keys: those use resource-based policies.
✓Benefits and use cases
VPC sharing: one network account, many app accounts.
One Transit Gateway or Network Firewall policy used everywhere.
Shared Private CA, IPAM pools, Resolver rules and DNS Firewall rule groups.
VPC sharing in practice
In VPC sharing the network account owns the VPC and shares subnets with participant accounts in the same organization. Participants launch their own EC2 instances, RDS databases and Lambda functions into the shared subnets. Each participant owns and pays for its own resources and can’t see or change other participants’ resources or the subnet, route tables and NACLs. The owner can’t change participant resources either. This splits duties well: the network team controls routing and inspection; app teams control their workloads. Firewall Manager itself uses RAM to share Network Firewall and DNS Firewall rule groups, which is why RAM sharing is one of its prerequisites.
Think of it like · a shared office building
Many companies, one building owner.
AWS concept
Familiar thing
Resource owner
≈
The landlord who owns the building and pays for repairs
Resource share
≈
The lease that lists which floors, which tenants, which rights
Managed permission
≈
The lease rules: you may use the meeting rooms, not repaint them
Inside the organization
≈
Staff of sister companies get keys automatically
Outside the organization
≈
An outside company must sign and return the lease first
VPC sharing
≈
Tenants bring their own furniture into floors the landlord maintains
Real AWS example · share subnets with an OU
Enable org sharing once, then share two subnets with the Workloads OU.
No invitation is sent; accounts in the OU see the subnets at once.
Exam-style scenario
A network team wants 25 application accounts in the organization to use a central VPC’s private subnets, so all traffic goes through one inspection path. Application teams must manage their own instances but must not change routing. Sharing outside the organization must be impossible. What should the team do?
A. Create VPC peering from each account to the central VPC.
B. Enable RAM sharing with Organizations, share the subnets with the application OU, and add an SCP that denies resource shares allowing external principals.
C. Share the VPC with a Service Catalog portfolio.
D. Give application teams an IAM role in the network account.
Show the worked answer
Answer: B
VPC sharing through RAM lets participants launch resources while the owner keeps routing; the SCP blocks external shares.
Why not the others
A: 25 peerings, each team still needs its own VPC and routing.
C: Service Catalog shares templates, not live subnets.
D: Gives teams access to the network account, including routing.
How the exam tests this
“Share subnets or a Transit Gateway with other accounts”→ AWS RAM.
“Org members should get access without accepting invitations”→ Enable sharing with AWS Organizations in RAM.
“Prevent sharing with accounts outside the org”→ Share setting + SCP on ram:RequestedAllowsExternalPrincipals.
“Give principals fewer actions than the default”→ Customer managed permission.
“Cross-account access to a KMS key”→ Key policy, not RAM.
Must remember
Share = resources + principals + managed permission.
In org: no invitation; outside: must accept.
Enable org sharing in RAM, from the management account.
Cheatsheet extras: CloudFormation service roles, iam:PassRole and stack condition keys
Your cheat sheet has a warning that this lecture only touched: whoever can run a CloudFormation stack can borrow the permissions of the stack’s service role. That is a classic privilege escalation path, and it is also how you safely let developers deploy without giving them admin rights. The cheat sheet also lists IAM condition keys that control which templates and roles may be used.
Concept profile
CloudFormation service role
often confused with the caller’s own credentials
?What is it?
An IAM role that trusts cloudformation.amazonaws.com. When a stack has a service role, CloudFormation uses that role to create, update and delete the stack’s resources, instead of the permissions of the person who runs the stack operation.
⚙How does it work?
You choose the role with --role-arn when creating or updating a stack. To do that you need iam:PassRole on that role.
Without a service role, CloudFormation uses a temporary session from your credentials, so you need permission for every resource in the template.
Once a stack has a role, CloudFormation keeps using it. Anyone allowed to operate on that stack (update, delete, run a change set) gets the role’s power for those operations, even without PassRole.
Limit this with IAM condition keys: cloudformation:RoleArn (which service role must be used), cloudformation:TemplateUrl (only templates from an approved bucket), cloudformation:ResourceTypes (only some resource types), cloudformation:ChangeSetName (naming rules).
Limit PassRole with iam:PassedToService = cloudformation.amazonaws.com.
{ }Structure
The developer passes a narrow role; CloudFormation does the work with that role.
CloudFormation actions + rights for every resource in the template
Least privilege for developers
Easy: no direct resource rights
Hard: developers need broad rights
Main risk
Anyone who can update the stack borrows the role
Developers can create resources outside CloudFormation too
StackSets equivalent
Administration role + execution role (Section 01)
n/a
!Common mistakes the exam tests
Giving iam:PassRole on "Resource": "*": users can pass an admin role to CloudFormation (or EC2, Lambda) and escalate.
Attaching an admin service role to a stack that many people can update.
Forgetting that a deploy role which can create IAM roles needs a permissions boundary condition, or it can create an admin role.
Thinking a stack policy limits who can deploy: it only protects resources inside a stack from updates.
Allowing templates from anywhere when the requirement says “only approved templates”: use cloudformation:TemplateUrl or Service Catalog.
✓Benefits and use cases
Developers deploy infrastructure without holding admin rights.
One audited deploy role per pipeline or team.
Force use of approved templates and resource types with IAM conditions.
Older material says AWS Firewall Manager manages only AWS WAF rules on CloudFront and ALBs, “not NACLs or security groups”. Today it manages WAF, Shield Advanced, security groups, network ACLs, Network Firewall, Route 53 Resolver DNS Firewall and third-party firewalls (see Section 04).
Think of it like · a company car with a driver
You don’t get the car keys; you tell the company driver where to go.
AWS concept
Familiar thing
Service role
≈
The company driver who has the car keys
iam:PassRole
≈
Permission to book that particular driver
cloudformation:RoleArn condition
≈
“You may only book driver No. 7”
cloudformation:TemplateUrl
≈
Only routes from the approved route book
Anyone who can update the stack
≈
Anyone who can ring the car can redirect the driver
Real AWS example · developer policy for safe deployments
Developers can run stacks only with one deploy role and only from the approved template bucket.
The developer has no direct EC2 or IAM rights, so everything goes through CloudFormation with CfnDeployRole.
Exam-style scenario
A team wants developers to deploy their own stacks with CloudFormation. Developers must not be able to create resources outside CloudFormation, and must not be able to use any role other than an approved deploy role. Which solution meets the requirements?
A. Give developers AdministratorAccess and a stack policy that denies updates.
B. Give developers CloudFormation permissions with a cloudformation:RoleArn condition and iam:PassRole only on the approved deploy role; give the deploy role the resource permissions.
C. Give developers iam:PassRole on all roles and CloudFormation full access.
D. Use drift detection to find resources created outside CloudFormation.
Show the worked answer
Answer: B
Developers hold only CloudFormation rights and can pass only the one role; the role does the work.
Why not the others
A: Admins can create anything directly; a stack policy only protects stack resources.
C: PassRole on all roles lets them pass an admin role.
D: Drift detection reports changes to stack resources; it doesn’t prevent anything.
How the exam tests this
“Developers deploy without broad permissions”→ CloudFormation service role + PassRole on that role only.
“Force a specific role for stack operations”→ cloudformation:RoleArn condition.
“Only templates from our bucket”→ cloudformation:TemplateUrl (or Service Catalog).
“User escalated by passing an admin role”→ Scope iam:PassRole resources + iam:PassedToService.
Must remember
Service role trusts cloudformation.amazonaws.com.
Setting it needs iam:PassRole; later stack users borrow it.
17. CFN service role: setting it needs iam:PassRole; stack users borrow it.
18. Force the role: cloudformation:RoleArn; approved templates: TemplateUrl.
10
Core quiz
Check the basics first. Pick an answer, then press Check.
11
Hard quiz
Harder than most real exam questions on purpose, with one “choose two” and one matching question. Aim for 9 out of 12 before Day 3.
12
Practice test questions (from your mock exams)
Five questions about baselines across accounts, tags and Service Catalog. These questions come from your own mock exams in the practice tests folder, matched to this lecture. Each one was checked against current AWS behavior, so some wording and answers are updated; the source is shown at the end of each explanation.
13
Hands-on lab (30 minutes, low cost)
On your laptop, install the tools (pip install cfn-lint, and cfn-guard from its GitHub releases). Write a small template with one S3 bucket and a typo in a property name. Run cfn-lint and read the error. Fix it, then write the s3.guard rule from section 2 and run cfn-guard validate until it passes. This step is free.
In one account, create the two self-managed StackSet roles (AWS provides sample templates for AWSCloudFormationStackSetAdministrationRole and AWSCloudFormationStackSetExecutionRole). Create a StackSet with your bucket template and deploy it to your own account in two Regions.
In the S3 console, change the bucket’s tags or versioning by hand. Run Detect drift on the StackSet and find the MODIFIED resource and the property difference.
If you have a test organization: create a tag policy for CostCenter, attach it to a test account, and view compliance in Resource Groups > Tag policies. Try launching a t3.micro with and without the tag after attaching the SCP from section 3, then terminate it at once.
In AWS RAM, create a resource share for a managed prefix list (free) and look at the managed permission it uses. Delete the share.
Clean up: delete the stack instances, then the StackSet; empty and delete the buckets; detach and delete the SCP and tag policy; delete the prefix list. Don’t create a Firewall Manager policy in a personal account just to try it: you pay per policy per Region, plus AWS Config recording in every account in scope.