AWSTemplateFormatVersion: "2010-09-09"
Description: Service Catalog Resources

Parameters:
  CloudFormationBucket:
    Type: String

Resources:
  Portfolio:
    Type: "AWS::ServiceCatalog::Portfolio"
    Properties:
      ProviderName: Alter Way
      DisplayName: Main Portfolio

  S3BucketProduct:
    Type: AWS::ServiceCatalog::CloudFormationProduct
    Properties:
      Owner: Alter Way
      Description: S3 Bucket
      Name: s3-bucket
      ProvisioningArtifactParameters:
        - Description: Just a simple S3 bucket
          Info:
            LoadTemplateFromURL: !Sub https://s3-eu-west-1.amazonaws.com/${CloudFormationBucket}/service-catalog/s3-bucket-v10.yml
          Name: v1.0
        - Description: Simple S3 bucket with some more options (encryption, versioning, lifecycle)
          Info:
            LoadTemplateFromURL: !Sub https://s3-eu-west-1.amazonaws.com/${CloudFormationBucket}/service-catalog/s3-bucket-v11.yml
          Name: v1.1

  S3BucketPortfolioProductAssociation:
    Type: "AWS::ServiceCatalog::PortfolioProductAssociation"
    Properties:
      AcceptLanguage: en
      PortfolioId: !Ref Portfolio
      ProductId: !Ref S3BucketProduct

  PortfolioPrincipalAssociation:
    Type: "AWS::ServiceCatalog::PortfolioPrincipalAssociation"
    Properties:
      PrincipalARN: arn:aws:iam::000111222333:role/my-example-role
      PortfolioId: !Ref Portfolio
      PrincipalType: IAM

  TagOptionForDepartment:
    Type: AWS::ServiceCatalog::TagOption
    Properties:
      Active: true
      Value: IT
      Key: Department

  AssociationForTagOptionForDepartment:
    Type: AWS::ServiceCatalog::TagOptionAssociation
    Properties:
      TagOptionId: !Ref TagOptionForDepartment
      ResourceId: !Ref Portfolio
