Giter VIP home page Giter VIP logo

Comments (5)

hnnasit avatar hnnasit commented on July 21, 2024

Hi @yan-olydis, thanks for reporting the issue. Could you share your template file? SAM CLI does not cover resolving all the intrinsic functions and from the traceback, this might be throwing an error because of that.

from aws-sam-cli.

yan-olydis avatar yan-olydis commented on July 21, 2024

this is my template
AWSTemplateFormatVersion: '2010-09-09'

Parameters:

General parameters

EnvType:
Description: Environment Type
Type: String
AllowedValues:
- development
- staging
- production

DBInstanceClass:
Description: Instance class
Type: String

isEnableDeletionProtection:
Description: Enable Deletion Protection
Type: String
Default: false
AllowedValues:
- true
- false

isEnableBackup:
Description: Enable DocumentDB Backup
Type: String
Default: false
AllowedValues:
- true
- false

Conditions:
isProduction: !Equals [ !Ref EnvType, "production" ]
isDev: !Equals [ !Ref EnvType, "development" ]

Mappings:
Network:
development:
NbAzs: 3
CidrBlockPrefix: 10.1
CidrBlock: 10.1.0.0/16
staging:
NbAzs: 3
CidrBlockPrefix: 10.2
CidrBlock: 10.2.0.0/16
production:
NbAzs: 3
CidrBlockPrefix: 10.3
CidrBlock: 10.3.0.0/16

Resources:
Network:
Type: AWS::CloudFormation::Stack
Properties:
StackName: my-vpc
TemplateURL: 'network/vpc.yml'
Parameters:
EnvType: !Ref EnvType
RegionAzs: !FindInMap [Network, !Ref EnvType, NbAzs]
CidrBlockPrefix: !FindInMap [Network, !Ref EnvType, CidrBlockPrefix]

EcsCluster:
Type: AWS::CloudFormation::Stack
Properties:
StackName: my-ecs
TemplateURL: 'ecs/ecs.yml'
Parameters:
EnvType: !Ref EnvType
VpcId: !GetAtt Network.Outputs.VpcId
CidrBlockPrefix: !FindInMap [Network, !Ref EnvType, CidrBlockPrefix]

LoadBalancing:
Type: AWS::CloudFormation::Stack
Properties:
StackName: my-nlb
TemplateURL: 'nlb/nlb.yml'
Parameters:
VpcId: !GetAtt Network.Outputs.VpcId
PrivateSubnets: !GetAtt Network.Outputs.PrivateSubnets
PrivateHostedZoneId: !GetAtt Network.Outputs.PrivateHostedZoneId

DocumentDB:
Type: AWS::CloudFormation::Stack
DependsOn:
- Encryption
Properties:
StackName: my-database
TemplateURL: 'db/db.yml'
Parameters:
EnvType: !Ref EnvType
PrivateSubnets: !GetAtt Network.Outputs.PrivateSubnets
AvailabilityZones: !GetAtt Network.Outputs.AvailabilityZones
EncryptionKeyId: !GetAtt Encryption.Outputs.EncryptionKeyId
DBInstanceClass: !Ref DBInstanceClass
isEnableDeletionProtection: !Ref isEnableDeletionProtection
isEnableBackup: !Ref isEnableBackup
VpcId: !GetAtt Network.Outputs.VpcId

Encryption:
Type: AWS::CloudFormation::Stack
Properties:
StackName: my-encryption-key
TemplateURL: encryption/encryption.yml
Parameters:
EnvType: !Ref EnvType

from aws-sam-cli.

hnnasit avatar hnnasit commented on July 21, 2024

Thanks for providing the template file. I tried running sam build on the below template, but the command succeeds for me. I don't see any lambda/serverless functions in the template you provided as well. Would you be able to provide the nested stack templates? My guess is there is some intrinsic function in that template which SAM CLI does not support.

template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  sam-app-6787

  Sample SAM Template for sam-app-6787

Parameters:     
  EnvType:
    Description: Environment Type
    Type: String
    AllowedValues:
      - development
      - staging
      - production

  DBInstanceClass:
    Description: Instance class
    Type: String

  isEnableDeletionProtection:
    Description: Enable Deletion Protection
    Type: String
    Default: false
    AllowedValues:
      - true
      - false

  isEnableBackup:
    Description: Enable DocumentDB Backup
    Type: String
    Default: false
    AllowedValues:
      - true
      - false

  Conditions:
    isProduction: !Equals [ !Ref EnvType, "production" ]
    isDev: !Equals [ !Ref EnvType, "development" ]

  Mappings:
    Network:
      development:
        NbAzs: 3
        CidrBlockPrefix: 10.1
        CidrBlock: 10.1.0.0/16
      staging:
        NbAzs: 3
        CidrBlockPrefix: 10.2
        CidrBlock: 10.2.0.0/16
      production:
        NbAzs: 3
        CidrBlockPrefix: 10.3
        CidrBlock: 10.3.0.0/16

Resources:
  Network:
    Type: AWS::CloudFormation::Stack
    Properties:
      StackName: my-vpc
      TemplateURL: 'nested-template.yaml'
    Parameters:
      EnvType: !Ref EnvType
      RegionAzs: !FindInMap [Network, !Ref EnvType, NbAzs]
      CidrBlockPrefix: !FindInMap [Network, !Ref EnvType, CidrBlockPrefix]

  EcsCluster:
    Type: AWS::CloudFormation::Stack
    Properties:
      StackName: my-ecs
      TemplateURL: 'nested-template.yaml'
    Parameters:
      EnvType: !Ref EnvType
      VpcId: !GetAtt Network.Outputs.VpcId
      CidrBlockPrefix: !FindInMap [Network, !Ref EnvType, CidrBlockPrefix]

  LoadBalancing:
    Type: AWS::CloudFormation::Stack
    Properties:
      StackName: my-nlb
      TemplateURL: 'nested-template.yaml'
    Parameters:
      VpcId: !GetAtt Network.Outputs.VpcId
      PrivateSubnets: !GetAtt Network.Outputs.PrivateSubnets
      PrivateHostedZoneId: !GetAtt Network.Outputs.PrivateHostedZoneId

  DocumentDB:
    Type: AWS::CloudFormation::Stack
    DependsOn:
      - Encryption
    Properties:
      StackName: my-database
      TemplateURL: 'nested-template.yaml'
    Parameters:
      EnvType: !Ref EnvType
      PrivateSubnets: !GetAtt Network.Outputs.PrivateSubnets
      AvailabilityZones: !GetAtt Network.Outputs.AvailabilityZones
      EncryptionKeyId: !GetAtt Encryption.Outputs.EncryptionKeyId
      DBInstanceClass: !Ref DBInstanceClass
      isEnableDeletionProtection: !Ref isEnableDeletionProtection
      isEnableBackup: !Ref isEnableBackup
      VpcId: !GetAtt Network.Outputs.VpcId

  Encryption:
    Type: AWS::CloudFormation::Stack
    Properties:
      StackName: my-encryption-key
      TemplateURL: 'nested-template.yaml'
    Parameters:
      EnvType: !Ref EnvType

from aws-sam-cli.

mildaniel avatar mildaniel commented on July 21, 2024

Closing due to inactivity.

from aws-sam-cli.

github-actions avatar github-actions commented on July 21, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

from aws-sam-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.