Skip to content

Commit

Permalink
Enable APIG logging across accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
tmclaugh committed Oct 21, 2024
1 parent 60c13b0 commit a64ccd8
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stacksets-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Parameters:
Default: r-c834

Resources:
ApigLoggingStackSet:
Type: AWS::Serverless::Application
Properties:
Location: "./stacksets/apig-logging/stackset.yaml"
Parameters:
TargetOuIds: !Ref TargetOuIds
TargetRegions: us-east-1

BillingStackSet:
Type: AWS::Serverless::Application
Properties:
Expand Down
37 changes: 37 additions & 0 deletions stacksets/apig-logging/stackset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Metadata:
localTemplateFile: &template_body ./template.yaml

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS account infrastructure stackset (APIG Logging)

Parameters:
TargetOuIds:
Type: CommaDelimitedList
Description: List of OUs
TargetRegions:
Type: CommaDelimitedList
Description: Regions to deploy to

Resources:
OrgBilling:
Type: AWS::CloudFormation::StackSet
Properties:
StackSetName: ApigLogging
Description: API Gateway Logging
CallAs: DELEGATED_ADMIN
StackInstancesGroup:
- DeploymentTargets:
OrganizationalUnitIds: !Ref TargetOuIds
Regions: !Ref TargetRegions
AutoDeployment:
Enabled: true
RetainStacksOnAccountRemoval: false
ManagedExecution:
Active: true
OperationPreferences:
RegionConcurrencyType: PARALLEL
FailureToleranceCount: 1
MaxConcurrentCount: 5
PermissionModel: SERVICE_MANAGED
TemplateBody: *template_body
22 changes: 22 additions & 0 deletions stacksets/apig-logging/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS APIG Logging'

Resources:
CloudWatchRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
Action: 'sts:AssumeRole'
Effect: Allow
Principal:
Service: apigateway.amazonaws.com
Path: /
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs'

ApigAccount:
Type: AWS::ApiGateway::Account
Properties:
CloudWatchRoleArn: !GetAtt CloudWatchRole.Arn
5 changes: 5 additions & 0 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Parameters:


Resources:
ApigLoggingStack:
Type: AWS::Serverless::Application
Properties:
Location: "./stacksets/apig-logging/template.yaml"

BillingStackManagement:
Type: AWS::Serverless::Application
Properties:
Expand Down

0 comments on commit a64ccd8

Please sign in to comment.