I have a resource in my cloudformation stack as follows:
"CodePipelineStack":{
"Type":"AWS::CodePipeline::Pipeline",
"DependsOn":["CodeBuildJavaProject","Git"],
"Properties":{
"RoleArn":{
"Fn::Join":[
"",
[
"arn:aws:iam::",
{
"Ref":"AWS::AccountId"
},
":role/",
{
"Ref":"CodePipelineRole"
}
]
]
},
"Stages":[
{
"Name": "Source",
"Actions": [
{
"InputArtifacts": [],
So far so good. As you can see there is a dependency on another resource called Git. However in my Git resource I have:
"Git":{
"Type":"AWS::CloudFormation::Stack",
"Condition" : "isNewGitRepo",
"Properties":{
"TemplateURL":"..../git.json",
"TimeoutInMinutes":"60",
"Parameters" : {
"OutputBucketName" : {"Ref":"OutputBucketName"},
"AllowedIps" : {"Ref":"AllowedIps"},
"ApiSecret" : {"Ref":"ApiSecret"},
"GitToken" : {"Ref":"GitToken"},
"OauthKey" : {"Ref":"OauthKey"},
"OauthSecret" : {"Ref":"OauthSecret"}
}
}
}
So as you see in Git there is a condition in which if it is true Git will be created and if not then my issue starts since the second resource depends on the creation of the first one and if the first one is not created the second will not as well and that is the issue since I want the codepipeline get created anyway so if "Condition" : "isNewGitRepo" is true in Git resource then CodePipelineStack should wait for the Git resource to get created if not then it should get created without caring about Git. Something like this:
"CodePipelineStack":{
"Type":"AWS::CodePipeline::Pipeline",
"DependsOn":{"Fn::If": ["isNewGitRepo",
["CodeBuildJavaProject","Git"],"CodeBuildJavaProject"]}
"Properties":{
"RoleArn":{
"Fn::Join":[
"",
[
"arn:aws:iam::",
{
"Ref":"AWS::AccountId"
},
":role/",
{
"Ref":"CodePipelineRole"
}
]
]
},
"Stages":[
{
"Name": "Source",
"Actions": [
{
"InputArtifacts": [],
I mean this part:
"DependsOn":{"Fn::If": ["isNewGitRepo",["CodeBuildJavaProject","Git"],"CodeBuildJavaProject"]}
But not working. Any idea? How can I implement it?