CloudFormation/Windows/cascading-images-with-dotnet-web-application/windows-baseline-stack.yml [177:244]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Status: ENABLED
      Tags:
        Purpose: ImageBuilderSample

  # A CloudFormation export is used to allow future stacks to use the output image from this stack.
  # As an Image ARN uses lowercase names, we will use a custom Lambda Function to transform the
  # name to lowercase.
  LowerCaseLambda:
    Type: AWS::Lambda::Function
    Properties:
      Description: Returns the lowercase version of a string
      MemorySize: 256
      Runtime: python3.8
      Handler: index.lambda_handler
      Role: !GetAtt LowerCaseLambdaRole.Arn
      Timeout: 30
      Code:
        ZipFile: |
          import cfnresponse

          def lambda_handler(event, context):
              output = event['ResourceProperties'].get('InputString', '').lower()
              responseData = {'OutputString': output}
              cfnresponse.send(event, context, cfnresponse.SUCCESS, responseData)

  # The CloudWatch Log Group for the Lambda Function.
  RecipeLogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub '/aws/lambda/${LowerCaseLambda}'
      RetentionInDays: 3

  # The IAM Role for the Lambda Function
  LowerCaseLambdaRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action:
              - sts:AssumeRole
      Policies:
        - PolicyName: lambda-write-logs
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: "Allow"
                Action:
                  - logs:CreateLogGroup
                  - logs:CreateLogStream
                  - logs:PutLogEvents
                Resource: arn:aws:logs:*:*

  # Invokes the Lambda Function to ensure a lowercase resource name is available.
  LowerCaseImageName:
    Type: Custom::Lowercase
    DependsOn:
      - RecipeLogGroup
    Properties:
      ServiceToken: !GetAtt LowerCaseLambda.Arn
      InputString: !Ref ResourceName

Outputs:
  # The EC2 Image Builder Image ARN. For use in future stacks that will build cascading images with this image as their source.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



CloudFormation/Windows/cascading-images-with-dotnet-web-application/windows-dotnet-application-stack.yml [437:504]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Status: ENABLED
      Tags:
        Purpose: ImageBuilderSample

  # A CloudFormation export is used to allow future stacks to use the output image from this stack.
  # As an Image ARN uses lowercase names, we will use a custom Lambda Function to transform the
  # name to lowercase.
  LowerCaseLambda:
    Type: AWS::Lambda::Function
    Properties:
      Description: Returns the lowercase version of a string
      MemorySize: 256
      Runtime: python3.8
      Handler: index.lambda_handler
      Role: !GetAtt LowerCaseLambdaRole.Arn
      Timeout: 30
      Code:
        ZipFile: |
          import cfnresponse

          def lambda_handler(event, context):
              output = event['ResourceProperties'].get('InputString', '').lower()
              responseData = {'OutputString': output}
              cfnresponse.send(event, context, cfnresponse.SUCCESS, responseData)

  # The CloudWatch Log Group for the Lambda Function.
  RecipeLogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub '/aws/lambda/${LowerCaseLambda}'
      RetentionInDays: 3

  # The IAM Role for the Lambda Function
  LowerCaseLambdaRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action:
              - sts:AssumeRole
      Policies:
        - PolicyName: lambda-write-logs
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: "Allow"
                Action:
                  - logs:CreateLogGroup
                  - logs:CreateLogStream
                  - logs:PutLogEvents
                Resource: arn:aws:logs:*:*

  # Invokes the Lambda Function to ensure a lowercase resource name is available.
  LowerCaseImageName:
    Type: Custom::Lowercase
    DependsOn:
      - RecipeLogGroup
    Properties:
      ServiceToken: !GetAtt LowerCaseLambda.Arn
      InputString: !Ref ResourceName

Outputs:
  # The EC2 Image Builder Image ARN. For use in future stacks that will build cascading images with this image as their source.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



