title: How to dynamically create one input with the value of another in AWS step function states?
body: <p>I want to make the output of a state on the basis of input it received.</p>
  
  <p>I have created a generic activity <code>CopyFileActivity</code> that copies a file from one S3 bucket to another. 
  As a intial input it the name of external service, execute some other activities and then executes <code>CopyFileActivity</code> activity. 
  I have a folder corresponding to each service. Is there a way to dynamically know the name of folder as an input of <code>CopyFileActivity</code>?</p>
  
  <p>Intial input is as below:</p>
  
  <pre><code>{
      "service": "xyz"
  }
  </code></pre>
  
  <p>My S3 folder structure is like <code>external-test-&lt;service_name&gt;</code>, for this particular case as <code>external-test-xyz</code>.</p>
  
  <p>I want the input of <code>CopyFileActivity</code> activity as:</p>
  
  <pre><code>{
      "sourceBucket": "external-test-xyz",
      "destBucket": "internal-test-xyz"
  }
  </code></pre>
  
  <p>NOTE - prefixes <code>external-test-</code> and <code>internal-test-</code> are fixed.</p>
  
  <p>Various ways:</p>
  
  <ol>
  <li>Changing the code of activity and create the <code>sourceBucket</code> and <code>destBucket</code> itself in activity instead of passing as input. But I want to make this activity generic, since It would be used in many other scenario.</li>
  <li><p>Changing the initial input as:</p>
  
  <pre><code>{
      "service": "xyz",
      "sourceBucket": "external-test-xyz",
      "destBucket": "internal-test-xyz"
  }
  </code></pre>
  
  <p>This would work, but <code>sourceBucket</code> and <code>destBucket</code> are redundant params. It can also produce bug as someone gives might give bucket names.</p></li>
  <li><p>A pass state where required params would be created</p>
  
  <pre><code>{
        "Type": "Pass",
        "Parameters": {
          "service.$": "$.service",
          "sourceBucket.$": "external-test-", (something logic here)
          "destBucket.$": "internal-test-", (same logic here)
          "fileName": "fileName"
        },
        "Next": "CopyFileActivity"
  }
  </code></pre></li>
  </ol>
  
  <p>I tried doing things like <code>"sourceBucket.$": "external-test-" + "$.service"</code>, but not correct.</p>
  
  <p>Is there any way to do this or can anyone please suggest any other approach to deal with this problem.</p>