AWS Cloud Formation Conditions on DependsOn
<p>I am writing a cloud formation template and the creation of a resource in my stack it depends on the environment. <br>
Therefore, I check the value of a parameter (Environment), and based on it I create that resource (Condition: ISProduction).<br>
However, my problem is that in case that resource is created (MyProductionResource) another resource (AnotherResource) becomes dependent on it and needs to use an output attribute from the other (MyProductionResource).<br>
Here the code:</p>

<pre><code>Conditions:
  ISProduction:
    "Fn::Equals":
      - !Ref Environment
      - production
 ...

 MyProductionResource:
    Type: AWS::CloudFormation::Stack
    Condition: ISProduction
    Properties:
    [.. properties..]

 AnotherResource:
    Type: AWS::CloudFormation::Stack
    DependsOn:
      - AResource
      - MyProductionResource
    Properties:
      TemplateURL: whatever
      Parameters:
        AParameter: !GetAtt MyProductionResource.Outputs.SomeString
</code></pre>

<p>My problem is that I want AnotherResource to be dependent on MyProductionResource only when ISProduction is true. An idea is to add some kind of conditions in the DependsOn item, or anything that would bring to the same result.  <br>
How can I do that on AWS Cloud Formation?<br>
Also I am not sure what happen when the resource that is listed in the dependsOn list is not created. Would the cloud formation template generate an error? How can I make this attribute read safety !GetAtt MyProductionResource.Outputs.SomeString ?</p>